繁体   English   中英

在htaccess重定向中忽略特定文件夹

[英]Ommitting a specific folder in htaccess redirect

我试图将一堆支持文件重定向到不同的支持系统,除了其中包含文件夹software_updates任何文件。 以下是我写的规则。

RewriteRule ^/support/.*(?!software_updates).*$ newurl_location [NC,L,R=301]

这不包括/support/software_updates/但不/support/product/software_updates我试图在支持后排除任何在URL中任何位置具有software_updates的URL。

尝试:

RewriteRule ^/support/(?!.*software_updates) newurl_location [NC,L,R=301]

我没有Apache方便测试它,但它应该工作。

我已对此进行了测试并相信它正是您所寻找的(请注意/.*的更改)

RewriteRule ^support/(?!.*?software_updates) newurl_location [NC,L,R=301]

你快到了。

首先,你不需要初始/

你不想要.*(?!software_updates).* ,因为这会匹配software_updates 为什么? 点星吃掉了整个字符串,最后,你得到的断言是software_updates不是下一个。 当然这是事实。

这应该可以解决问题。

RewriteRule ^support/(?!.*software_updates).*$ newurl_location [NC,L,R=301]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM