php - 如何使用 .htaccess 检测浏览器

标签 php html .htaccess wap wml

我想使用 .htaccess 检测用户浏览器并在用户未从手机进入网站时重定向

最佳答案

你可以开始here举个例子。

# Rewrite requests from all user-agents except modern Internet Explorer, Firefox, Opera
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/4\.[0-9]+\ \(compatible;\ MSIE\ [0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/5\.0 \(([^;]+;\ )*[^;]+\)\ Gecko/2[0-9]{3}\ Firefox/[0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Opera/[0-9.]+
RewriteRule .* X.html [L]

根据需要进行调整。

关于php - 如何使用 .htaccess 检测浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6236444/

相关文章:

php - 如何从 MySQLi 准备好的语句中查看呈现的(原始)查询?

css - 固定占位符 Bootstrap

javascript - 如何在 onmouseleave 和点击鼠标左键时触发一些功能?

php - 从 header 下载时缺少文件扩展名

php - 如何在 .htaccess 中编写 rewriteCond 以排除子目录及其子目录

javascript - PHP 的 sprintf 函数的 JavaScript 等价物是什么?

php - 使用 GROUP BY 从 MySQL 进行查询不起作用

php - 如何向mysql php结果添加增量

html - 是否必须使用 thead、tbody 和 tfoot 标签?

apache - HTACCESS 通过 HTTPS 重定向添加 WWW