我想在我的网站上建立新的网址结构:
/page.php?id=1 -> /服务条款
/page.php?id=2 -> /faq
所以我在htaccess做了:
RewriteRule ^terms-of-service /page.php?id=1 [L,NC,QSA]而且很好,当我去mysite.com/服务条款时,我可以看到我的第一页,但我也想把301从旧地址重定向到新地址。当我试图这样做的时候:
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule ^page.php$ terms-of-service? [L,R=301,NC]
RewriteRule ^terms-of-service /page.php?id=1 [L,NC,QSA]我的浏览器中有一个“无效重定向”错误。我怎么才能修好它?
发布于 2015-03-21 18:00:03
您的规则将导致重定向循环。您需要在这里使用%{THE_REQUEST}。以这种方式:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /page\.php\?id=1\s [NC]
RewriteRule ^ terms-of-service? [L,R=301]
RewriteRule ^terms-of-service/?$ page.php?id=1 [L,NC,QSA]https://stackoverflow.com/questions/29184728
复制相似问题