2
我一直在尋找從www.domain.com重定向我的網站domain.com的nginx的網址從萬維網重定向到沒有WWW爲HTTPS
我跟着這個Nginx no-www to www and www to no-www
但是對於普通http://www.domain.com它重定向到domain.com的
但是當我嘗試https://www.domain.com它保持原樣,不重定向到https://domain.com
我不知道我錯過了什麼
server {
listen 80;
server_name www.domain.com;
// $scheme will get the http protocol
// and 301 is best practice for tablet, phone, desktop and seo
return 301 $scheme://domain.com$request_uri;
}
server {
listen 80;
server_name domain.com;
// here goes the rest of your config file
// example
location/{
rewrite ^/cp/login?$ /cp/login.php last;
// etc etc...
}
}
請考慮發佈您的nginx配置。 – bredikhin
我遵循http://stackoverflow.com/questions/7947030/nginx-no-www-to-www-and-www-to-no-www的第一個答案,我編輯了我的問題哪一個我從鏈接 –
,因此,那麼你可能在錯誤的端口上收聽https,下面的答案是非常簡單的。 – bredikhin