根据浏览器头判断是手机还是电脑访问

    当一个域名对应一个PC端和mobile端的网站时,我们需要根据浏览器的header头做跳转判断,最简单的就是通过js来实现:

<script type="text/javascript">
    var isOnPc=!(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent));
    if(isOnPc){
        self.location="/pc/index.html";
    }else{
        self.location="/mobile/index.html";
    }
</script>