Apache mod_rewrite%{HTTP_USER_AGENT}不等于+或条件(列表) [英] Apache mod_rewrite %{HTTP_USER_AGENT} not equal + or condition (list)
本文介绍了Apache mod_rewrite%{HTTP_USER_AGENT}不等于+或条件(列表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前的状况是这样的:
My current condition is like that:
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
我想知道如何将此条件转换为上述值之一的if not
.
I wonder how can I swap this condition into if not
one of the values above.
我对这样的事情很坚强:
I tought about something like that:
RewriteCond %{HTTP_USER_AGENT} !="android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
但它不起作用.
推荐答案
问题是您在opera
和mobile
之间留有空格,这导致mod_rewrite将其解析为多个参数.尝试使用括号代替引号和!
并转义空格:
The problem is you've got a space between opera
and mobile
, which causes mod_rewrite to parse it as multiple parameters. Try using parentheses instead of quotes in conjunction with !
and escape the space:
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile) [NC]
这篇关于Apache mod_rewrite%{HTTP_USER_AGENT}不等于+或条件(列表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文