Home  >  Article  >  Backend Development  >  怎么识别为手机端访问

怎么识别为手机端访问

WBOY
WBOYOriginal
2016-06-13 11:15:17875browse

如何识别为手机端访问?

NGINX服务器可否实现识别手机端访问,然后再rewrite一下?

如果是PHP文件本身识别,那就是通过请求的头部信息了,对吧。。但这样的跳转不好吧。


------解决方案--------------------
<br>function isMobile() {       <br>    $user_agent = $_SERVER['HTTP_USER_AGENT'];       <br>    $mobile_agents = Array("240x320", "acer", "acoon",   <br>        "acs-", "abacho", "ahong", "airness", "alcatel",   <br>        "amoi", "android", "anywhereyougo.com",   <br>        "applewebkit/525", "applewebkit/532", "asus",   <br>        "audio", "au-mic", "avantogo", "becker", "benq",   <br>        "bilbo", "bird", "blackberry", "blazer", "bleu",   <br>        "cdm-", "compal", "coolpad", "danger", "dbtel",   <br>        "dopod", "elaine", "eric", "etouch", "fly ",   <br>        "fly_", "fly-", "go.web", "goodaccess",   <br>        "gradiente", "grundig", "haier", "hedy",   <br>        "hitachi", "htc", "huawei", "hutchison",   <br>        "inno", "ipad", "ipaq", "ipod", "jbrowser",   <br>        "kddi", "kgt", "kwc", "lenovo", "lg ", "lg2",   <br>        "lg3", "lg4", "lg5", "lg7", "lg8", "lg9", "lg-",   <br>        "lge-", "lge9", "longcos", "maemo", "mercator",   <br>        "meridian", "micromax", "midp", "mini", "mitsu",   <br>        "mmm", "mmp", "mobi", "mot-", "moto", "nec-",   <br>        "netfront", "newgen", "nexian", "nf-browser",   <br>        "nintendo", "nitro", "nokia", "nook", "novarra",   <br>        "obigo", "palm", "panasonic", "pantech", "philips",   <br>        "phone", "pg-", "playstation", "pocket", "pt-",   <br>        "qc-", "qtek", "rover", "sagem", "sama", "samu",   <br>        "sanyo", "samsung", "sch-", "scooter", "sec-",   <br>        "sendo", "sgh-", "sharp", "siemens", "sie-",   <br>        "softbank", "sony", "spice", "sprint", "spv",   <br>        "symbian", "tablet", "talkabout", "tcl-",   <br>        "teleca", "telit", "tianyu", "tim-", "toshiba",   <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn