php服务器端检查手机访问还是pc访问(并跳到不同页面)
2014-04-25 11:36
375 查看
<?php function is_mobile(){ //正则表达式,批配不同手机浏览器UA关键词。 $regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"; $regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"; $regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"; $regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"; $regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"; $regex_match.=")/i"; return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT'])); //如果UA中存在上面的关键词则返回真。 } if(is_mobile()) { //如果为真,则进行WAP页面。 header( "HTTP/1.1 301 Moved Permanently"); header("Location: http://www.966266.com/wap.php"); }else { //如果为假,则进行WEB页面。 header( "HTTP/1.1 301 Moved Permanently"); header("Location: http://www.966266.com/"); } ?>
相关文章推荐
- php服务器端检查手机访问还是pc访问(并跳到不同页面)
- php判断是手机还是pc访问从而走不同url
- php判断是手机还是pc访问从而走不同url
- tp3.2后台判断手机登录还是pc端登录,跳转不同页面
- 服务器端判断是PC访问还是手机访问
- 服务器端判断是PC访问还是手机访问
- php 判断手机访问还是pc访问
- js,php实现用ua判断手机,ipad,pc浏览器访问网页不同尺寸页
- 根据不同访问设备跳转到PC页面或手机页面
- 根据不同访问设备跳转到PC页面或手机页面
- 用PHP检测用户是用手机(Mobile)还是电脑(PC)访问网站
- php 用于检测是PC还是手机访问
- 服务器端判断是PC访问还是手机访问
- 服务器端判断是PC访问还是手机访问
- 前端 js 判断设备类型是手机还是PC 并打开不同设备下的页面
- 网页判断是手机访问还是PC访问
- PHP识别电脑还是手机访问网站
- 怎样辨别网站推广优化中,网站的访问来源是通过手机移动端访问过来的还是pc电脑端访问进来的?
- 怎样用php识别是电脑还是手机访问网站
- php如何判断用户通过手机wap访问还是电脑直接访问