nginx根据http_useragent判断是手机端还是pc端
nginx的location判断用户端是手机还是pc端配置配置判断 pc 和 mobile 的 H5location / {set $is_mobile false;#设置一个初始值if ( $http_cookie ~* "ACCESS_TERMINAL=mobile" ) {#判断匹配手机端set $is_mobile true;}if ($http_user_agent ~
·
nginx的location判断用户端是手机还是pc端配置
配置
判断 pc 和 mobile 的 H5
location / {
set $is_mobile false; #设置一个初始值
if ( $http_cookie ~* "ACCESS_TERMINAL=mobile" ) { #判断匹配手机端
set $is_mobile true;
}
if ($http_user_agent ~* (android|ip(ad|hone|od)|kindle|blackberry|windows\s(ce|phone))) { #匹配手机端类型
set $is_mobile true;
}
if ($is_mobile = true) {
root /usr/local/openresty/nginx/html/mobile/;
break;
}
root /usr/local/openresty/nginx/html/pc/;
}
更多推荐
所有评论(0)