说明: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/;
}
时间: 2024-10-06 20:24:31