說明:nginx 不支持&& 和嵌套if判斷
#多重判斷,匹配移動端和http_host爲xxx.com跳轉到m.xxx.com
set $flag 0;
if ( $http_user_agent ~ "(iPhone)|(Android)" ) {
set $flag "${flag}1";
}
if ( $http_host ~* "^(xxx\.com)$" ) {
set $flag "${flag}1";
}
if ( $flag = "011" ) {
rewrite ^(.*) http://m.xxx.com/;
}