0

This may be a 'fashion' question, but is it better to redirect:

https://www.example.com -> https://example.com or https://example.com -> https://www.example.com?

I always assumed it was better to have people bookmark the www site instead of the TLD root, to save lookups to the root (as that's mixed in with MX records and other lookups).

I've noticed some browsers 'hide' the www prefex, and insert it if there's no response on the root, so users may not even be aware nowadays.

Which way is better and why? Does it really matter?

I am not asking 'how' - I know how to do this either way - I'm asking 'why' and 'which way'.

In the 'early days' you were encouraged to use www.example.com, but things change ...

3
  • In my opinion, it's better to not redirect at all.
    – paladin
    Feb 10 at 13:30
  • So people going to the root get nothing? Or
    – J. Gwinner
    Feb 12 at 4:20
  • No, you host the website just on both domains.
    – paladin
    Feb 12 at 9:49

2 Answers 2

2

The www. prefix is a remnant from the glorious old 90s when you had a single machine for each service, like FTP, WWW, SMTP etc. and had to use a separate hostname for each one. The apex/bare domain usually went for an SMTP server as the apex was historically used for email before the invention of WWW.

Nowadays, everything is WWW. Browsers dropped support for protocols other than HTTP/HTTPS. Everyone is typing example.com into their address bars, not www.example.com, especially on their phones/tablets. It is painful to pronounce www in English. From the UX point of view, the www. prefix is atavism and was considered archaic even in 2010 - see this question on SO.

From the technical point of view, there are no such limitations such as "You can only have a single A and/or AAAA record at the apex/null/bare domain". There are no technical standards imposing such limitations. You can find multiple A/AAAA records on such domains as microsoft.com, amazon.com, netfix.com, cloudflare.com etc. Unless my memory fails me, Google also used to have multiple addresses for their services in the past.

There is one technical limitation with the apex domain. You can't have CNAME as the apex RR which limits the use of CDNs or platform hosting services which want your domain to be a CNAME pointing to their service domain. You need to host your DNS with these services in order to use such services with your apex domain. If you want to use CloudFlare, you need to use their DNS with CNAME flattening. If you want to use AWS CloudFront, you need to use their Route53 DNS with ALIAS records.

From SEO point of view, there is no difference between www.example.com and example.com as long as you have only one of them as a canonical URL and redirect another to the canonical one (or embed link rel=canonical but this is going to create a mess in a browser history). But once you select one and start redirecting, you can't go the other way later because 301 redirects Moved Permanently are stored by browsers forever. That is why the old sites like google.com, microsoft.com, apple.com etc. are stuck with www. prefix.

Chrome tries to fix this mess by hiding www. prefix in the UI. There are no browsers that add www. on their own unless there is a redirect from the bare domain. The use of www. prefix as a canonical URL adds unnecessary redirects for most users who prefer to type a shorter bare domain.

I would recommend using a bare domain unless you need a CNAME for some service but this service doesn't provide its own DNS (or has some features missing in their DNS) or if you can't move DNS to this service for some reason.

1
  • Thank you for the very complete discussion. Cheerfully upvoted.
    – J. Gwinner
    Feb 16 at 2:56
0

You can only have a single A and/or AAAA record at the apex/null/bare domain. That's rather restrictive (you can't do RR-DNS, geo-aware DNS becomes tricky). Since modern browsers will automatically add the 'www.' to something you type in the address bar, www.example.com should be the canonical name.

10
  • 1
    Can you give a reference to an RFC that prohibits multiple A/AAAA records for the apex? Can you add a reference that modern browsers automatically add the 'www.' to something you type in the address bar?
    – AlexD
    Feb 10 at 0:32
  • 1
    serverfault.com has two A (but zero AAAA) on apex and works fine. (Same for superuser.com stackoverflow.com stackexchange.com unsurprisingly.) Feb 10 at 0:55
  • 1
    Can't find a reference off the top of my head - and it does indeed appear that some stackoverflow sites have multiple sites. Historically bind would not prevent you configuring stuff this way but a few years ago I found several providers would not permit this (and confirmed the specs at that time). This may have changed. But even if that's the case, that doesn't mean every provider implements this.
    – symcbean
    Feb 10 at 1:35
  • 1
    Google Bard agrees with me: "DNS Standard: The Domain Name System (DNS) standard, RFC 1035, explicitly forbids multiple A records for the apex domain. This restriction ensures consistency and avoids ambiguity in resolving the root of a domain."
    – symcbean
    Feb 10 at 1:39
  • 1
    @symcbean, are you aware that LLMs hallucinate a lot? RFC 1035 doesn't say anything close to "explicitly forbid multiple A records for the apex domain".
    – AlexD
    Feb 10 at 8:16

You must log in to answer this question.

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