判断UA这种事不能说的太明。
【微博】 Mozilla/5.0 (Linux; U; Android 4.2.2; zh-cn; GT-I9502 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
【chrome】 Mozilla/5.0 (Linux; Android 4.2.2; GT-I9502 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.64 Mobile Safari/537.36
【猎豹】 Mozilla/5.0 (Linux; Android 4.2.2; GT-I9502 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.64 Mobile Safari/537.36
【海豚】 Mozilla/5.0 (Linux; U; Android 4.2.2; zh-cn; GT-I9502 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
【UC】 Mozilla/5.0 (Linux; U; Android 4.2.2; zh-CN; GT-I9502 Build/JDQ39) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.4.2.365 U3/0.8.0 Mobile Safari/533.1
【baidu】 Mozilla/5.0 (Linux; U; Android 4.2.2; zh-cn; GT-I9502 Build/JDQ39) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baidubrowser/4.2.13.3 (Baidu; P1 4.2.2)
【QQ】 MQQBrowser
【搜狗】 SogouMSE, SogouMobileBrowser
【小米】 XiaoMi/MiuiBrowser
【遨游】 Maxthon
【欧朋】 Opera, Oupeng
--------------------------------------
/* function check_useragent(){ var bool_result='success'; var pattern=/micromessenger|360browser|360|MQBrowser\/(.*?)\s+\(iPhone;|Mozilla\/(.*?)\s+\(iPhone;|sina_weibo/i; var useragent='<?php echo strtoupper($_SERVER['HTTP_USER_AGENT']);?>'; var referer = '<?php echo strtoupper($_SERVER['HTTP_REFERER'])?>'; if(useragent.indexOf(('360ee').toUpperCase()) != -1 || useragent.indexOf(('360se').toUpperCase()) != -1) { // location.href= "http://pc.huochepiao.360.cn"; return; } if(!useragent.match(pattern)){ bool_result=useragent.indexOf(('Android').toUpperCase())==-1?'failed_pc':'failed_mb'; } return bool_result; } <?php if(@$_SERVER['SERVER_NAME']!='10.16.15.227'&&@$_SERVER['SERVER_NAME']!='12306.com'){?> var sta=check_useragent(); if(sta=='failed_pc'){ if(navigator.userAgent.indexOf('iPhone')>-1){ location.href='error.html?pc'; }else{ location.href='errorpc.html'; } } else if(sta=='failed_mb'){ if(referer.indexOf('weibo.cn') > -1) { if(navigator.userAgent.indexOf('MQQBrowser')>-1 || navigator.userAgent.indexOf('SogouMSE')>-1 || navigator.userAgent.indexOf('SogouMobileBrowser')>-1 || navigator.userAgent.indexOf('XiaoMi')>-1 || navigator.userAgent.indexOf('MiuiBrowser')>-1 || navigator.userAgent.indexOf('Maxthon')>-1 || navigator.userAgent.indexOf('Opera')>-1 || navigator.userAgent.indexOf('Oupeng')>-1 || navigator.userAgent.indexOf('UCBrowser')>-1){ location.href='error.html?mb'; } } else { location.href='error.html?mb'; } } <?php }?> */