Search code examples
webdnsipsubdomain

What is the correct DNS record setup for www subdomain?


I would like to set up my web app to use the "www" subdomain as my primary url. I'll be using a service to handle 301 redirects from my naked/apex domain to my subdomain (example.com -> www.example.com). What is the correct DNS record type for my "www" subdomain? Cant seem to find a clear answer on this.

  • An "A" record pointing to my websites IP address?
  • A "CNAME" pointing to my naked/apex domain?

Solution

  • It's CNAME. A record is pointing to the webserver IP address. CNAME will serve as an alias. Commonly when example.com and www.example.com points to the same application and hosted by the same server. To avoid maintaining two different records, it's a best practice to create an A record for example.com pointing to the server IP address and a CNAME record for www.example.com pointing to example.com