Hello,
I'm having a hard time trying to serve my website from https://www.example.com. For WordPress sites, WordPress automatically takes care of this, but this is a static site (built with Eleventy+Bulma).
What I desire:
httpS://www.example.com => 200
http://www.example.com => 301 => httpS://www.example.com
httpS://example.com => 301 => httpS://www.example.com
http://example.com => 301 => httpS://www.example.com
Default behaviour:
https://www.example.com => 200
http://www.example.com => 301 => https://www.example.com
https://example.com => 200
http://example.com => 301 => https://example.com
I've already read this post and I created a file named force-www.conf in /etc/nginx/conf.d/ with the suggested code:
server {
server_name "~^(?!www\.).*" ;
return 301 $scheme://www.$host$request_uri;
}
After reloading the Nginx confix, this doesn't seem to have any effect. Even rebooting the entire server made no difference. It appears there's a config elsewhere which overrides this.
I can add the www prefix in force-ssl-example.com.conf to get this redirect working:
http://example.com => 301 => https://www.example.com
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://www.$host$request_uri;
}
That leaves https://example.com => https://www.example.com which I can't figure out how to get working.
Any guidance will be highly appreciated.
Thank you!