Rewrite condition to check mobile user agent from smart phones

一个人想着一个人 提交于 2019-12-13 19:08:23

问题


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:


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



来源:https://stackoverflow.com/questions/18981991/rewrite-condition-to-check-mobile-user-agent-from-smart-phones

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!