我在.htaccess设置上遇到了一些问题. 我的网站主页网址为: www.domain/b/zh-CN index.php ,然后使用mod_rewrite创建漂亮的url: www.domain. com/en
I have some problems with .htaccess settings. My Website home page url is : www.domain/b/en/index.php ,and I use mod_rewrite to create pretty url : www.domain/en
这是我对漂亮网址的重写规则(有效):
This is my rewrite rules for pretty urls (It works):
RewriteRule ^en/(.*)$ /b/$1 [L,QSA,NC,PT]这是我想要的漂亮网址,但是当我将旧网址"重定向到新网址时,就会出现一些问题.
That's pretty urls what I want, but when I redirect "old urls" to new urls, there are some problems.
我的Chrome浏览器显示"www.domain redirected you too many times."
My Chrome browser shows "www.domain redirected you too many times."
这是我的旧网址重定向到新规则:
This is my old urls redirect to new rule:
RewriteRule ^b/en/(.*)$ /en/$1 [NC,L,R=301]推荐答案
这是一个通用的两部分问题.您需要将原始请求重定向到更漂亮的一个:
This is a generic 2-part problem. You'll need to redirect the raw request to prettier one:
RewriteRule ^en/(.*)$ /b/en/$1 [L,QSA,NC] RewriteCond %{THE_REQUEST} ^GET\ /b/(en)/(\S*) [NC] RewriteRule ^b/ /%1/%2 [R=301,L]在测试新规则之前,请确保清除浏览器的缓存.
Be sure to clear your browsers' cache before testing the new rules.
更多推荐
将旧网址重写为漂亮的网址,并使用.htaccess将旧网址重定向到新网址
发布评论