问题描述
例如 https://www.example.com/cat/cat1/cat2?brand=HP
为 https://www.example.com/cat/cat1/cat2/HP
。
我的 .htaccess
看起来像这样:
RewriteBase /
RewriteEngine On
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.example.com/$1 [NC,R=301,L]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^index\.PHP$ https://www.example.com/$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
类别设置正确,但过滤器始终以原生方式显示 ?key=valye&key2=value2
等。
解决方法
考虑到您想点击 https://www.example.com/cat/cat1/cat2/HP
,然后尝试跟随。请在测试您的网址之前清除浏览器缓存。
RewriteEngine ON
RewriteBase /
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.example.com/$1 [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*) $1?brand=$2 [L]