网上有很多的关于PC跳转到移动端页面的写法了,这里有一个在nginx上配置的方法,对于提升页面效率非常有用:
#----- redirect to mobile check (starts) -----# set $mobile_rewrite do_not_perform; # this regex string is actually much longer to match more mobile devices if ($http_user_agent ~* "|android|ip(ad|hone|od)|UCBrowser") { set $mobile_rewrite perform; } if ($mobile_rewrite = perform) { rewrite ^ https://移动端域名$request_uri? redirect; #注意协议 break; } #----- redirect to mobile check (ends) -----#