![](/img/trans.png)
[英]htaccess redirectmatch regular expression to avoid infinite loop
[英]Configure RedirectMatch for last part without infinite loop
目前,我正在尝试在htaccess文件中编写301 RedirectMatch
。 但是,匹配的URL也会在我重定向到的URL上触发,从而导致无限循环。
当我的网址以/profile/herman-visser
我想重定向到/profile/herman-visser/photos
。 我正在使用以下规则:
RedirectMatch 301 /profile/(.*) /profile/$1/photos
这是/profile/herman-visser/photos
但是当我要转到/profile/herman-visser/photos
,也会触发该规则,从而导致/photos/photos/photos/photos
等
有人可以帮助我找到正确的解决方案吗?
您需要排除要重定向到的目标
RedirectMatch 301 /profile/((?!.*/photos).*)$ /profile/$1/photos
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.