简体   繁体   English

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

[英]Ommitting a specific folder in htaccess redirect

Im trying to redirect a bunch of support files to a different support system except for any files that have the folder software_updates in them. 我试图将一堆支持文件重定向到不同的支持系统,除了其中包含文件夹software_updates任何文件。 the following is the rule that I wrote. 以下是我写的规则。

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

this excludes /support/software_updates/ but not /support/product/software_updates Im trying to exclude any URL that has software_updates anywhere in the URL after support. 这不包括/support/software_updates/但不/support/product/software_updates我试图在支持后排除任何在URL中任何位置具有software_updates的URL。

Try: 尝试:

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

I don't have Apache handy to test it, but it should work. 我没有Apache方便测试它,但它应该工作。

I have tested this and believe that it is what you're looking for (please note the changes in the / and the .* ) 我已对此进行了测试并相信它正是您所寻找的(请注意/.*的更改)

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

You were nearly there. 你快到了。

First off, you don't need the initial / 首先,你不需要初始/

You don't want .*(?!software_updates).* , because this will match software_updates . 你不想要.*(?!software_updates).* ,因为这会匹配software_updates Why? 为什么? The dot-star eats the whole string, then, at the end, you have the assertion that software_updates is not next. 点星吃掉了整个字符串,最后,你得到的断言是software_updates不是下一个。 And of course this is true. 当然这是事实。

这应该可以解决问题。

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

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

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