I'm using Namecheap Domains and Vultr Hosting.
I'm trying to redirect DNS www to non-www.
www.example.com to example.com
I contacted Vultr and asked how to do this with their DNS Manager, they said they would not help as it is self-managed. So I contacted Namecheap, they said they would not help becuase they don't have access to Vultr's DNS Manager, would not tell me if the records I showed them are correct, and I would need to contact Vultr. So I am in an endless support loop.
Vultr DNS Manager
I followed this answer on how to set up a CNAME to redirect to non-www.
Type???| Name?|?Data?????????|?Seconds
--------------------------------------
A????? |???? ?|?ipv4 address?|?300
AAAA ?|???? ?| ipv6 address | 300
CNAME ?|?.?? ?|?example.com??|?300
CNAME ?| www |?example.com??|?300
After waiting all night for it to propgate, the www can still be visited and does not redirect.
It does not allow me to make another A
record, only CNAME
. It says:
Unable to add record: A CNAME record is not allowed to coexist with any other data.
NGINX
I followed this guide and tried redirecting it with sites-available config. Http and Https work, but www does not redirect to non-www.
server {
# Redirect http to https
listen 80;
return 301 https://$host$request_uri;
}
server {
# Redirect www to non-www
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 443 ssl default_server;
ssl on;
ssl_certificate /etc/nginx/ssl/cert_chain.crt;
ssl_certificate_key /etc/nginx/ssl/example_com.key;
ssl_protocols TLSv1.1 TLSv1.2;
server_name example.com;
...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…