根据访问者客户端决定是否跳转到WAP网站
Contents
公司360mobile网站在建设中提出以下要求,来提高用户体验:
当访问者使用手机访问www域名时,自动跳转到wap域名。
演示地址(手机访问):
http://uicss.cn/test/mobile/
index.php插入代码如下:
<?php
$go2url = ‘http://uicss.cn/wap/index.php';
$ua = strtolower($_SERVER[‘HTTP_USER_AGENT’]);
$uachar = “/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|mobile)/i”;
if($ua == “ || preg_match($uachar, $ua)){
header(‘Location:‘.$go2url);exit;
}
?>