將網站從http轉換成https,無www轉到有www

非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;
    }
      
}
    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章