Question
non-www redirect not working
Non-www redirect to www is not working on my server. Here is the following nginx configuration that I’m using. When I try on mobile or on a desktop browser it doesn’t connect and says webpage is unavailable. In mobile gives an DNS look-up failed.
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.ca;
return 301 https://www.example.ca$request_uri;
}
server {
server_name www.example.ca;
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-www.example.ca.conf;
include snippets/ssl-params.conf;
.
.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×