将用户重定向到移动站点的最佳技术

Zul*_*din 1 javascript php apache

您最喜欢将用户重定向到自定义移动网站的技术是什么(例如:mysite.com - > m.mysite.com或mysite.com/m).

我试过检测移动浏览器 JS,看起来不错.但是,我可以看到,它首先加载主站点,并在所有主站点内容完全加载后,然后用户将被重定向到移动站点.这需要花费很多时间.

在此处分享您的建议和最佳实践指南.我也想学习.:)

谢谢.

cle*_*orn 5

我建议使用这个PHP库 http://code.google.com/p/php-mobile-detect/

if ($detect->isMobile()) {
    // any mobile platform
}
Run Code Online (Sandbox Code Playgroud)

例如,也可以像iOS那样进行特定的设备检测

if($detect->isiOS()){
    // code to run for the Apple iOS platform.
}
Run Code Online (Sandbox Code Playgroud)