问题描述
我正在尝试重写特定的PHP文件GET参数,但似乎无法正常工作.
I am trying to rewrite a specific PHP file GET parameter but cant seem to get things to work.
我要重写http://www.example.com/meeting.php?ref=y0fpjXrrGP
,所以它是http://www.example.com/meeting/y0fpjXrrGP
我在下面错什么?请注意,我使用的是WordPress,因此要添加到现有的htaccess文件中.
What am I mising on the below? Note I am using WordPress so adding to the existing htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^meeting/(.*)$ meeting.php?ref=$1
</IfModule>
# END WordPress
Options -Indexes
添加RewriteRule ^meeting/(.*)$ meeting.php?ref=$1
似乎根本不起作用.
Adding RewriteRule ^meeting/(.*)$ meeting.php?ref=$1
does not seem to work at all.
推荐答案
只需在您的.htaccess
文件中使用它:
Just use this in your .htaccess
file:
RewriteEngine On
RewriteRule ^meeting/([^/]*)$ /meeting.php?ref=$1 [L]
它将为您提供以下网址:http://www.example.com/meeting/y0fpjXrrGP
It will leave you with the URL: http://www.example.com/meeting/y0fpjXrrGP
请确保在测试时清除缓存.
Make sure you clear your cache when testing this.
这篇关于htaccess重写URL php参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!