2

I have purchased example.com and any request to this url hits my IP address which hosts an nginx web server.

This works when I enter example.com in the browser. However, when I enter www.example.com then it doesn't work. Do I need to change any setting at the DNS registrar to make this work?

0

1 Answer 1

8

Believe it or not, www. is a subdomain.

It is a widely accepted subdomain so people don't give it much thought, but it still is a subdomain.

In order for www. to work, you do need to add a DNS record for www.

This can either be an A record pointing to the ip address that is the same as domainnameexample.com (recommended) or a CNAME that points directly to domainnameexample.com.

Both A and CNAME will work, but an A record is recommended as it causes less overhead for the server as it might cause more queries overall.

If you use IPv6, make sure you also have an AAAA record unless you use CNAME, then the AAAA record of domainnameexample.com is automatically used if it exists.

7
  • CNAME records are cached in the same way, everywhere that I know of. Using them might result in more queries overall, but if the CNAME target is within the same zone, the entire chain will be resolved in the same query (the server automatically includes the following A/AAAA records). Jun 8, 2022 at 11:29
  • @user1686 right.. Updated the answer. I thought CNAME records were always queried not cached, but they are probably querying the local cache still.
    – LPChip
    Jun 8, 2022 at 11:33
  • Well, if the CNAME is pointing to some big CDN, then that target domain might be using very short TTLs for its A/AAAA records – 30 or 60 seconds is not an unusual sight for some of them, e.g. the CNAME at www.github.com on its own would be cached for a whole hour, but then it points to an A record at github.com that's cached for 60 seconds only (and in some cases that causes caches to apply the same 60s expiry to both cache entries), so there is certainly going to be a lot of queries for that – but it's only due to how the particular site operates. Jun 8, 2022 at 11:42
  • 1
    I suppose if the term subdomain applied to any record inside a domain, but my understanding of the term doesn't allow that. If you had a FQDN such as webhost12.www.exampledomain.com, then yes www would be a subdomain.
    – Chris O
    Jun 8, 2022 at 19:47
  • 2
    @ChrisO: The most widely used terminology is that any domain name below the root domain is a subdomain, it doesn't need to have children on its own (and it certainly doesn't need to be delegated via NS – the term "zone" is used for that). I think only e.g. MS DNS Server's management interface insists on using the term the way you do, but in general everywhere else the www indeed counts as a subdomain (and a hostname). Jun 9, 2022 at 3:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .