I am getting duplicate URLs on crawls of my Django site via my SEO tools and via Google tools. I want to ditch www.domain.com completely and redirect all traffic to https://domain.com
Below is my NGINX conf. Cerbot has added its https info. Curious what I’m doing wrong here.
server {
server_name domain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/domain/domain-django;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
server_name www.domain.com;
return 301 $scheme://domain.com$request_uri;
}
server {
if ($host = domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name domain.com;
return 404; # managed by Certbotserver
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Hi there,
Currently, you don’t have a redirect rule for
https://www.domian.com
tohttps://domian.com
. The redirects that you have are only forhttp://
.You can fix that by adding that redirect.
Here is an example:
Hope that this helps!
Best,
Bobby