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