重写条件以从智能手机检查移动用户代理

Pat*_*tan 2 apache mod-rewrite http

我正在编写重写条件来检查用户代理。

1. The request should be from Mobile and
2. The request should not be from iphone/Black Berry/Android Device/ Windows Phone
Run Code Online (Sandbox Code Playgroud)

我得到了这样的东西

RewriteCond %{HTTP_USER_AGENT} Mobile [AND]
RewriteCond %{HTTP_USER_AGENT} !"android|blackberry|IOS|windows phone" [NC]
Run Code Online (Sandbox Code Playgroud)

有人可以纠正这一点。

Jur*_*ens 5

RewriteCond %{HTTP_USER_AGENT} ^.*(Android|BlackBerry|iPhone|Windows Phone).*$ [NC]
RewriteRule ^(.+)$ /go_to_mobile_or_403/$1 [L]
Run Code Online (Sandbox Code Playgroud)

来源:http : //www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html#HTTP_USER_AGENT