重写条件检查从智能手机的移动用户代理(Rewrite condition to check mobi

2019-10-18 16:08发布

我写改写条件来检查用户代理。

1. The request should be from Mobile and
2. The request should not be from iphone/Black Berry/Android Device/ Windows Phone

我得到了一些这样的事

RewriteCond %{HTTP_USER_AGENT} Mobile [AND]
RewriteCond %{HTTP_USER_AGENT} !"android|blackberry|IOS|windows phone" [NC]

可有一个人纠正。

Answer 1:

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

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



文章来源: Rewrite condition to check mobile user agent from smart phones