htaccess:在参数中重写查询字符串的URL问题

时间:2016-01-20 11:13:47

标签: php .htaccess

我有从

重写网址的问题
Ä

http://localhost/cs/compare?slug=wash-safe-industries.html    

我在.htaccess中尝试过以下代码,但对我不起作用,我也搜索了各个网站,但仍面临问题

http://localhost/cs/compare/wash-safe-industries.html

还尝试了以下代码行

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/?compare/(.*?)/?$ /compare.php?slug=$1 [L]

请帮助我谢谢

3 个答案:

答案 0 :(得分:2)

/cs/子目录中尝试此.htaccess:

Options -MultiViews
RewriteEngine on
RewriteBase /cs/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^compare/(.+?)/?$ compare.php?slug=$1 [L,NC,QSA]

答案 1 :(得分:1)

尝试使用以下代码行:

Options -MultiViews
RewriteEngine On
RewriteRule ^compare/(.+?)/?$ compare.php?slug=$1 [L,NC,QSA]

答案 2 :(得分:0)

你必须写如下,试试这个。

  

RewriteRule ^ compare / wash-safe-industries.html compare?slug = wash-safe-industries.html

相关问题