检查移动设备的Apache和重定向到移动网站 [英] Check mobile device in apache and redirect to mobile website

查看:166
本文介绍了检查移动设备的Apache和重定向到移动网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查,如果用户正在使用移动设备或经常性的系统,并使用Apache重定向他要么移动或正常的网站。这可能吗?

I want to check if user is using mobile device or regular system and redirect him to either mobile or normal site using apache. Is this possible?

我试过code像

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://m.example.com/ [L,R=302]
</IfModule>

在.htacess并没有任何效果。这是正确的?

in .htacess and it did not have any effect. Is this correct ?

推荐答案

首先,你怎么测试此?

其次,请尝试以下重写规则,而不是你所使用的。

Secondly, try the following RewriteRule instead of the one you are using.

RewriteRule ^.*$ http://m.example.com/ [L,R=302]

最后,作为一个额外的忠告,我还要考虑以下几点:

Finally, as an extra piece of advice, i would also consider the following:


  • 使用阿帕奇移动过滤器,而不是一个正则表达式。它是更精确,并且提供的特征的更大范围的

  • 您应该允许用户选择重新presentation /体验,他们想要的。所以,如果你是$ P $与移动版psenting他们,那么你应该让他们选择的桌面版本,而不是因为这实际上有可能是他们想要的东西;反之亦然。

  • 这可能是原因过多比如他们的书签到桌面上,有人分享的URL桌面版本等等,等等你的内容协商的技术是pretty基本不考虑任何的这些用例。

这篇关于检查移动设备的Apache和重定向到移动网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆