2

我现在的情况是这样的:

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

我想知道如何将这种情况交换if not为上述值之一。

我对这样的事情很感兴趣:

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

但它不起作用。

4

2 回答 2

5

问题是你在operaand之间有一个空格mobile,这导致 mod_rewrite 将其解析为多个参数。尝试使用括号而不是引号,!并转义空格:

RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile) [NC]
于 2013-01-03T23:48:33.817 回答
0

非常接近,您不需要=在 negation 之后添加!

RewriteCond %{HTTP_USER_AGENT} !"android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
于 2013-01-03T12:29:31.190 回答