2010-04-24 75 views
0

我需要多少sentense,如果它不包含一些話 我寫這樣的的.htaccess:重寫規則問題

^([^news|home|rules|contacts|month_films|archive|ratings])$ 

,但它不工作。 你能告訴我爲什麼嗎?感謝

+4

關於該表達式的一切都很錯誤,我不確定你甚至試圖用它來做什麼。你能用簡單的英語解釋你想要做什麼? – Welbog 2010-04-24 13:20:24

+0

@Welbog我只需要找到sentense,如果它不包含任何這些詞(問題在其中)。 所以,當我寫^([^新聞|主頁|規則|聯繫| month_films |檔案|評級])$是真的嗎? – Simon 2010-04-24 13:23:09

回答

0

試試這個(無[]):

^(news|home|rules|contacts|month_films|archive|ratings)$ 
+1

但這完全符合「新聞」例如 - 我認爲他想匹配除*「新聞」等所有內容。 – Joscha 2010-04-24 13:44:15

1

在這種情況下,放!在正則表達式前使用RewriteCond:

RewriteCond %{REQUEST_URI} !(news|home|rules|contacts|month_films|archive|ratings) 
RewriteRule <whatever it is you want to do> 
+0

@Kinopiko它很有趣!但我不知道RewriteCond :( 什麼是{REQUEST_URI}? – Simon 2010-04-24 13:57:17

+0

請參閱Apache文檔。 – 2010-04-24 15:38:28