nginx配置实现非www跳www域名,移动端跳m移动端域名的方法
注意:nginx配置不支持 if ( && ) 以及 if 嵌套写法
if ($host = 'xxxx.com' ) {
rewrite ^ https://www.xxxx.com$uri permanent;
}
set $flag "0";
if ($host = 'www.xxxx.com') {
set $flag "${flag}1";
}
if ( $http_user_agent ~* "(Android|webOS|iPhone|iPad|BlackBerry)" ){
set $flag "${flag}1";
}
if ($flag = "011"){
rewrite ^/(.*)$ https://m.xxxx.com$uri permanent;
}