2013-01-03 44 views
2

我的當前狀態布萊恩那樣:mod_rewrite的%{HTTP_USER_AGENT}不等於+或條件(列表)

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC] 

我不知道如何可以互換這個條件爲「如果不是」上面的值中的一個。

我因子評分類似的東西:

RewriteCond %{HTTP_USER_AGENT} !="android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC] 

但它不工作。

回答

5

的問題是你有operamobile之間的空間,從而導致了mod_rewrite解析它作爲多個參數。嘗試使用圓括號而不是引號與!結合並轉義空格:

RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile) [NC] 
0

非常接近你不需要添加=否定!後。

RewriteCond %{HTTP_USER_AGENT} !"android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]