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

标签 apache http mod-rewrite

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

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]

谁能改正一下。

最佳答案

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

关于apache - 重写条件以从智能手机检查移动用户代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18981991/

相关文章:

php - mod_cgi、mod_fastcgi、mod_scgi、mod_wsgi、mod_python、FLUP。我不知道还有多少。什么是 mod_php 等价物?

apache - 如何阻止其他人的域名指向我的Apache托管网站?

django - 如何使用 Apache 和 mod_wsgi 为 django 网站单独设置 LD_LIBRARY_PATH

apache - 配置 Apache 将 "GET/user/foo"路由到/user/GET.php 并将 "PUT/user/foo"路由到/user/PUT.php

.htaccess - 使用和不使用 SSL 将 www 添加到 URL

Apache 重写到其他目录(如果那里存在文件)

apache - "Job for httpd.service failed because the control process exited with error code."我该如何解决这个问题?

http - 将参数传递到 servlet 时出错

http - 浏览器完整性检查 - NGINX

php - PHP 框架中的漂亮 URL