Closed Jogai closed 6 years ago
You're asking for the intentions behind a change I introduced over two years ago. I can't tell you exactly what my intentions were, but I think it was because back then letsecrypt.org did not support wildcart certficates I would have to request several letsencrypt certificates and implement a switch which decides which certificate to serve based on whether you're coming from www.example.com or example.com.
I can definitively tell you that it is my personal preference, though. I don't want identical content to have different URLs on my setups. This messes with certain systems like reddit's link-has-already-been-submitted feature.
The right way to handle www.-subdomains when they don't have different content than the main domain is to do a clean redirect to the main domain or the other way around. Source
I could have implemented this as a dialog instead, but it seems unnecessary to me.
If you want to have www. on a domain working you can easily run the script to set up www.example.com and then add the following to the config:
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://www.$host$request_uri;
}
server {
listen 443 ssl spdy;
listen [::]:443 ssl spdy;
server_name example.com;
return 301 https://www.$host$request_uri;
}
server{
listen 80;
listen [::]:80;
server_name www.example.com;
return 301 https://www.$host$request_uri;
server {
listen 443 ssl spdy;
listen [::]:443 ssl spdy;
server_name www.example.com;
#insert regular config here
}
This will redirect all traffic from example.com (http and https) to www.example.com (https). (Disclaimer: I came up with this on the fly, haven't tested it, but should world.)
Thanks for the answer. It doesn't matter its not exactly what you thought back then. Thanks for the examples too!
Piggybacking on this thread, guys, I would like to get your thoughts what if we develop a version of lempstack based on Ansible?
Well, I don't have any experience with Ansible, but judging from the documentation it should be fairly easy to implement an Ansible module/playbook/whatever.
However, I think this is not in the scope of this project.
Why is the question about redirecting www gone?