顶级域名处理方法
把不带www.的域名301跳转,比如http://xxx.com
- if ($host !~ www.xxxx.com){
- return 301 https://www.$host$request_uri;
- }
接下来还要处理http://www.xxx.com这种网址
- if ($server_port !~ 443){
- return 301 https://$host$request_uri;
- }
或者
- if ($server_port !~ 443){
- rewrite ^(/.*)$ https://$host$1 permanent;
- }
二级域名处理方法
把不包含www的二级域名301到https,比如bbs.xxx.com
- if ($server_port !~ 443){
- return 301 https://$host$request_uri;
- }
或者
- if ($server_port !~ 443){
- rewrite ^(/.*)$ https://$host$1 permanent;
- }