注意: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;
}

标签: none

添加新评论