非https与非www访问 设置
方法一:
server {
listen 80;
listen 443 ssl http2;
server_name www.91shiwan.com 91shiwan.com;
index index.html index.htm index.php;
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
if ($host ~ '^91shiwan.com'){
return 301 https://www.91shiwan.com$request_uri;
}
}
方法二:
server {
listen 80 default backlog=2048;
listen 443 ssl;
server_name www.91shiwan.com 91shiwan.com;
if ($host ~ '^91shiwan.com'){
return 301 https://www.91shiwan.com$request_uri;
}
}