我肯定在那里有一个答案,但是它确实让我耳目一新,并且我讨厌与.htaccess重定向有关的任何事情.
Im sure there is an answer out there for this somewhere but its doing my head in and I hate anything to do with .htaccess redirects.
基本上我正在尝试这样做
Basically I am trying to do this
RewriteRule /about/(.*) www.domain/example/about/$1 [R=301,L].问题在于,这导致重定向循环,因为从URL重定向到URL都包含"about".
Problem is that this results in a redirect loop because "about" is in both the redirected from and redirected to url.
id想要做的是拥有它,以便仅当根URL在/about/之前时才重定向.我确实尝试过这样做:
What id like to do is have it so that it will only redirect if the root url is before the /about/. I did try doing this with this:
RewriteRule www.domain/about/(.*) www.domain/example/about/$1 [R=301,L].但是那没用.
有人对此有直接解决方案吗?
Does anyone have a straight forward solution for this.
谢谢
推荐答案此规则应使用正则表达式模式中的锚点:
This rule should work with anchors in regex pattern:
RewriteRule ^/?(about/.*)$ /example/$1 [R=301,L,NC]^/?about仅匹配www.domain/about/,而不匹配www.domain/example/about/
更多推荐
.htaccess重定向,无重定向循环
发布评论