Rewrite condition to check mobile user agent from

2019-07-28 04:24发布

I am writing rewrite condition to check user agent.

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

I got some thing like this

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

Can some one correct this.

1条回答
Ridiculous、
2楼-- · 2019-07-28 05:12
RewriteCond %{HTTP_USER_AGENT} ^.*(Android|BlackBerry|iPhone|Windows Phone).*$ [NC]
RewriteRule ^(.+)$ /go_to_mobile_or_403/$1 [L]

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

查看更多
登录 后发表回答