0

我正在尝试获取 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] 会停止双重规则,但没有。谢谢你的帮助。

4

2 回答 2

0

这条规则很好:

RewriteRule ^cat/top/union-made/ /cat/top/union-made-in-usa [R=301,L]

但是您的旧规则需要调整以处理多路径深度并排除“联合制造”

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]
于 2012-07-20T00:12:16.033 回答
0

要保留友好的 URL 并防止循环,请改用:

RewriteRule ^cat/top/([a-z0-9_-]+)/?([a-z0-9_-]*) /cat/index.php?top=$1&pg=$2 [L,QSA]
于 2012-07-19T20:55:12.353 回答