i have been searching for redirecting my site from www.domain.com to domain.com
i followed this Nginx no-www to www and www to no-www
but for normal http://www.domain.com it is redirecting to domain.com
but when i try https://www.domain.com it stays as it is, not redirecting to https://domain.com
i don know what i'm missing
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...
}
}