2010-04-24 117 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