我想要得到 http://www.mysite.com/cat/top/union-made
前进到 http://www.mysite.com/cat/top/union-made-in-usa
但它似乎与我的动态重写混合,我得到了这个: http://www.mysite.com/cat/top/union-made-in-usa/2?topic=union-made&pg=
以下是我目前的htaccess规则:
RewriteRule ^cat/top/union-made/ /cat/top/union-made-in-usa [R=301,L]
#Redirect dynamic pages to static links
RewriteRule ^cat/top/([a-z0-9_-]+)/?([a-z0-9_-]*) /cat/index.php?top=$1&pg=$2 [NC,L]
我认为[L]会停止双重规则,但不会。谢谢你的帮助。
答案 0 :(得分:0)
要保留友好的网址并阻止循环,请改用:
RewriteRule ^cat/top/([a-z0-9_-]+)/?([a-z0-9_-]*) /cat/index.php?top=$1&pg=$2 [L,QSA]
答案 1 :(得分:0)
这条规则很好:
RewriteRule ^cat/top/union-made/ /cat/top/union-made-in-usa [R=301,L]
但是你的旧规则需要调整以处理多路径深度并排除“union-made”
RewriteCond %{REQUEST_URI} !union-made
RewriteRule ^cat/top/([a-z0-9_-]+)/([a-z0-9_-]*) /cat/index.php?top=$1&pg=$2 [NC,L]
# If the last bit of the path isn't there, you can handle it separately here:
RewriteCond %{REQUEST_URI} !union-made
RewriteRule ^cat/top/([a-z0-9_-]+)/? /cat/index.php?top=$1 [NC,L]