【问题标题】:Rewrite condition to check mobile user agent from smart phones重写条件以从智能手机检查移动用户代理
【发布时间】:2013-09-29 16:36:02
【问题描述】:

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

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]

有人可以纠正这个吗?

【问题讨论】:

    标签: apache http mod-rewrite


    【解决方案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

    【讨论】:

    • 感谢您的回复。但我也想添加不条件并检查手机。你也可以包括那个吗?
    • 如果您想检测功能手机,没有简单而精确的方法可以做到这一点。有 WURFL 但它相当“重”。尝试从以下方面获得一些灵感:mobiforge.com/designing/story/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    • 2013-10-29
    • 1970-01-01
    相关资源
    最近更新 更多