It’s no news by now that you know that your domain which is e.g domain.com is always attached with the “www” as this has become a standard way for people to access the url via the browser.
For newbies to DNS, All of a sudden, you discover there is a difference the day your domain is working and your www.domain.com doesnt work and then the quest for understanding and fix starts.
So lets talk about what makes all this happen in the DNS realm. DNS which stands for Domain Name System is like the Internet’s library of IPs.
A, CNAME, ALIAS and URL records are all possible solutions to point a host name (name hereafter) to your site. However, they have some small differences that affect how the client will reach your site.
Here’s the main differences:
The A record maps a name to one or more IP addresses, when the IP are known and stable.
The CNAME record maps a name to another name. It should only be used when there are no other records on that name.
The ALIAS record maps a name to another name, but in turns it can coexist with other records on that name.
The URL record redirects the name to the target name using the HTTP 301 status code.
So which one should you Use?
Setting up domains on WHM/Cpanel typically sets up www using the CNAME towards the main domain name. And if you check the Edit DNS Zone -> Domain -> in WHM/Cpanel, you will see the rest of the DNS data for your domain.
A rule of thumb anyways says, never use a CNAME for your main domain domain.com but while some say you can use CNAME for “www”, I say why not use an A record for your www too , if not for anything, you save time on resolving the url name to the IP.
A, CNAME, or ALIAS … the choice is yours depending on what you feel its best for your site.