重定向的URL不以特定的字符串开头 [英] Redirect URLs that do not start with specific string

查看:72
本文介绍了重定向的URL不以特定的字符串开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试进行重定向工作,但是我一直收到错误消息重定向太多 ...
我想重定向所有不以特定字符串开头的URL,我写了这篇文章和许多其他文章,但没有用:

good day everyone, I'm trying to get a redirection work but i keep getting the error "too many redirects"... I want to redirect all the URLs that do not start with a specific strings, I wrote this and many others but didn't work:

RewriteRule !^(?=string1)(?=string2)(?=string3)/(.*) / [R=301,L]

有什么问题吗? ?
谢谢

Is there anything wrong? Thanks

推荐答案

您需要在重定向中排除首页:

You need to exclude the homepage in your redirect:

RewriteRule ^(?!string1|string2|string3|$) / [R=301,L]

但是,只有清除浏览器缓存后,该功能才能起作用。当您这样做时,它将停止重定向太多次。

However, that will not work until you clear your browser cache. When you do that, it will stop redirecting too many times.

这篇关于重定向的URL不以特定的字符串开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆