2014-04-23 34 views
0

我試圖將一堆支持文件重定向到不同的支持系統,除了其中包含文件夾software_updates的任何文件。以下是我寫的規則。收集htaccess重定向中的特定文件夾

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

這排除/support/software_updates/但不/support/product/software_updates我試着去排除在支持後的URL的任何地方有任何software_updates URL。

+0

嘿rocketdoctor,這個問題解決了,還是你還在努力呢? – zx81

回答

0

這應該可以做到。

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

嘗試:

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

我沒有Apache的得心應手的測試,但它應該工作。

1

我測試了這一點,並認爲這是你在找什麼(請注意在/.*的變化)

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

你幾乎沒有。

首先,你不需要初始/

你不想.*(?!software_updates).*,因爲這將匹配software_updates。爲什麼?點星吃完整個字符串,然後,最後,你有斷言software_updates不是下一個。當然這是事實。