I have set up DNS for my website so that example.com
is an A
record (pointing to the IP), but I don't know what to do about www.example.com
.
I intend to add a CNAME
record www.example.com
so it would become an alias of example.com
.
BUT, I've been checking my settings with https://intodns.com and it shows:
ERROR: I could not get any A records for www.example.com!
The error clears if I change www
to A
record. Is there a "rule" requiring that?
The difference between having an A record vs CNAME for www would be an extra look up. In case of the CNAME the after figuring out that www is a CNAME to example.com, another look will be done for example.com.
Other than that if you are planning to use a CDN or a 3 party acceleration service then a CNAME would come into play. Example a lookup of www.google.com results in the following. Notice the difference in TTL of www.l.google.com and www.google.com
This gives the flexibility of changing the record, keeping a lower TTL, doing fancy stuff like geo redirection, if employing third party services.
In your case it doesn't matter since you are pointing both to the same IP.
There is no rule that the
www.
address needs to be an A record. It is very common for a web site to be aCNAME
to something else. For example:Or:
If things aren't working for you, it suggests a configuration error. Without seeing your actual DNS records it's hard to help out, but using command line tools like
dig
can help you debug the problem by showing you exactly what DNS records are being exposed by your name servers.