One nginx host file which handles domain.tld and www.domain.tld with and without https and redirects all of them to use https and www
server { | |
listen 80; | |
listen [::]:80; | |
server_name domain.tld www.domain.tld; | |
return 301 https://www.domain.tld$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name domain.tld; | |
return 301 https://www.domain.tld$request_uri; | |
# include your HTTPS config here | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name www.domain.tld; | |
root /whatever/your/webroot/is; | |
# include your HTTPS config here | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment