单独设置某个域名强制跳转https,其它域名不跳转

笔记心得 0

Nginx

set $flag 0;
if ($host ~ '^要跳转的域名'){
 set $flag "${flag}1";
}
if ($server_port !~ 443 ){
 set $flag "${flag}1";
}
if ($flag = '011'){
 rewrite ^(/.*)$ https://$host$1 permanent;
}