Apache mod_rewrite%{HTTP_USER_AGENT}不等于+或条件(列表)

Ida*_*lan 2 apache .htaccess mod-rewrite redirect

我目前的情况是这样的:

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
Run Code Online (Sandbox Code Playgroud)

我想知道如何将这个条件换成if not上面的一个值.

我做了类似的事情:

RewriteCond %{HTTP_USER_AGENT} !="android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

Jon*_*Lin 5

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

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