[英]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.