nginx配置http强制跳转https
7232708273 2023-1-25

把不带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;
    }

 

最新回复 (1)
全部楼主
  • ccccc
    2月前 2
    0
    感谢楼主ing!!!
返回