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


htaccess: Rewrite URL issue for query string in parameter

>我在重写网址时遇到问题

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

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

我尝试过遵循.htaccess中的代码,但对我不起作用,我也搜索了各种网站,但仍然面临问题

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?compare/(.*?)/?$ /compare.php?slug=$1 [L]

还尝试了以下代码行

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

请帮助我谢谢

/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]

尝试使用以下代码行:

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

你必须这样写,试试这个。

重写规则 ^compare/wash-safe-industries.html 比较?slug=wash-safe-industries.html