20

For a website, e.g. example.co.uk, when I write it in the URL bar of browser, it takes me to the URL https://example.co.uk.

When I enumerate the subdomains of the website, I get subdomains like www.example.co.uk, kneal.example.co.uk, www.kneal.example.co.uk, sink.example.co.uk, www.sink.example.co.uk etc.

When I visit e.g. kneal.example.co.uk and www.kneal.example.co.uk in the browser, I see the same webpage. I have been observing it for a while and this is always the case.

When I perform vulnerability assessment scans on e.g. sink.example.co.uk and www.sink.example.co.uk, I get the exact same vulnerabilities. Even if I perform a site-structure enumeration of the website, I see the exact same site-structure. I have been observing it for a while and this is always the case.

Are subdomains of websites that start with www., same thing (with two different names - one starting with www. and one starting without www.) as those subdomains which do not start with www.?

If so (that is if they are not different), why do I get both something.example.co.uk and www.something.example.co.uk when enumerating example.co.uk?

5
  • 13
    It is usually better to configure one to redirect to the other rather than serving the exact same content for both. Commented Oct 5, 2022 at 9:41
  • 3
    I don't think it's actually that common for a subdomain to also have a www. entry. For example www.developers.google.com is not configured. Commented Oct 5, 2022 at 20:37
  • 1
    @IllusiveBrian The colloquial definition of "sub-domain" is actually quite hard to define in technical terms; from a technical point of view, "www.something.example.com", "www.example.co.uk", and "www.example.uk.com" are all at the same level of the hierarchy, and "example.com" is just a sub-domain of "com". To distinguish them, you need a "public suffix list", which will list ".com", ".co.uk" and ".uk.com" as public suffixes.
    – IMSoP
    Commented Oct 6, 2022 at 12:04
  • 1
    I think the answer to this question combines historical naming conventions for domain names, with DNS and HTTP protocol semantics. For one part of the answer, see What is the purpose of the WWW subdomain? over at SuperUser.SE. Commented Oct 6, 2022 at 12:56
  • 2
    One case where you can see the difference is email. Chances are that [email protected] does not arrive. That's the same Domain Name System (DNS), just a different record type. The www subdomain typically does not have a mail (MX) record.
    – MSalters
    Commented Oct 6, 2022 at 16:08

6 Answers 6

26

They aren't necessarily the same, but the convention is to configure them to work that way. But it's just a convention, and there are sites where it does make a difference.

6
  • 3
    Do you know of any examples where they serve different content (other than the trivial case of one redirecting to the other)? I know it'd be trivial to set up an example, I just don't know of any that exist "in the wild", so to speak. Commented Oct 5, 2022 at 22:10
  • 11
    @GordonDavisson, for many years, the website for the US National Hurricane Center was www.nhc.noaa.gov. A bare "nhc.noaa.gov" wouldn't connect.
    – Mark
    Commented Oct 6, 2022 at 0:57
  • 2
    It is entirely the configuration of the website administrator to configure www.<domain> to point to the standard root <domain>, but strictly speaking, they can make it to whatever they want. There's no regulatory body to specify what www (or any subdomain for that matter) should be doing. If it is misconfigured, it'll just not work.
    – Nelson
    Commented Oct 6, 2022 at 14:25
  • 2
    @GordonDavisson The Farnell website is a good example. Instead of buying domain names with the TLDs for each country, they simply have "farnell.com" and then use different subdomains for individual countries. So https://uk.farnell.com/ gives different results from https://de.farnell.com/.
    – Graham
    Commented Oct 6, 2022 at 17:49
  • 3
    @GordonDavisson It used to be very common in the late 90s/early 00s that the domain without "www" just didn't work. Or if it's traffic not actually going to a web server, for example I wouldn't expect ftp: //www. ftp. example. com: 21/ to work. (Neither of those are really different content, but it used to actually matter.) (Amusingly, SE tried to smartly link my example link--not displaying "www" and spoiling the point.) Commented Oct 6, 2022 at 19:45
19

Subdomains named www (for World Wide Web) are not special compared to other subdomains. That is, there is no mechanical reason for a domain to be named www.example.com instead of hello.example.com. Both of them are simply subdomains of example.com, which is a subdomain of the top-level domain com. Each of them could resolve to the same or to different servers, depending on their DNS entries. And, since the HTTP protocol requires browsers to use the Host header, to let servers know through which domain name they were accessed, servers can freely choose to serve the same or different content.

It is generally accepted to use either example.com or www.example.com as your official domain name, and have the other automatically redirect to the equivalent page with the domain name changed. Other subdomains usually serve different content, like that for a sub-organisation, for a specific user (like how Tumblr serves Neil Gaiman's blog on neil-gaiman.tumblr.com) or for different communities (like Stack Overflow), but they don't have to.

And since subdomains can have subdomains of their own, website owners could decide that they'd prefer to use www.specific-subdomain.example.com over specific-subdomain.example.com, but that's not fundamentally different from the choice to have something like incredibly.nested.specific-subdomain.example.com.

So the answer to your question is domains with www. and without www. are not the same. Unless the server is configured to make it the same.

2
  • 4
    Note that browsers automatically sent users to "www." version when on autocompletes address with "Ctrl+Enter"... so if your site still cares about desktop users it is smart idea to support both... Commented Oct 6, 2022 at 16:10
  • 3
    I just signed up in this SE to say that today I learned that www is just a subdomain and www.google.com is no different to maps.google.com or photos.google.com. I have configured a reverse proxy with traefik and I have some subdomains hanging below my domain and never did I noticed that www is no special. My head hurts from this realization. Thank @Jasmijn for the enlightenment
    – mrbolichi
    Commented Oct 7, 2022 at 10:40
9

This depends how it is set up in DNS. You will likely find that www is a CNAME (an alias) of the main domain - especially on a cpanel server. But this is only convention, it is a subdomain just like all the other subdomains.

You could have the www subdomain be a completely different website, but you would only confuse people.

7
  • 16
    A CNAME alias does NOT cause them to be the same. A CNAME points the name to the same server as some other name, but even then it is the web server which determines whether or not the two will have the same content or not. Serving the same content for both is usually accomplished with virtual host configuration. You could achieve the same thing by pointing both DNS records to the same server with A records. The type of DNS record used is totally irrelevant. Other than that technical detail, your answer is spot on. Commented Oct 5, 2022 at 9:38
  • 4
    If anyone is confused about how the web server could possibly know the domain with which you connect, it has been a required field in the HTTP request header since HTTP 1.1. I remember this one baffling me when I was younger.
    – Muzer
    Commented Oct 5, 2022 at 15:49
  • 3
    ....however in 2022, the webserver gets this from the SNI sent in the TLS HELLO.
    – symcbean
    Commented Oct 5, 2022 at 20:54
  • 2
    @symcbean: What webserver uses the SNI for "virtual hosting"? It's definitely required for TLS to work with independent certificates for each website hosted, but I don't think anything cares about it in the HTTP layer.
    – Oskar Skog
    Commented Oct 6, 2022 at 8:45
  • 2
    But what does that have to do with virtual hosting? The SNI exists to let the TLS layer know which certificate it should send, but I don't think the webserver itself cares about it.
    – Oskar Skog
    Commented Oct 6, 2022 at 10:59
8

To add to existing answers, a large (and recent) contributor to this confusion is Google Chrome's series of decisions to "simplify" the address bar, which results in hiding the www. prefix if present.

dumbing down the internet one release at a time

So if a user manually enters the address with www., the bar always shows it without www., even if the website is actually configured to prefer www., and in fact 301 redirects to it from the bare/naked domain. I can see how this therefore makes people think www. and no www. is the same thing. It takes focusing on the address bar twice to reveal the actual full domain name and if it has a www. or not.

Lastly, if you're deciding on www. for your site, here are some articles providing background on the issue and arguing you may want it for cookie efficiency and CNAME convenience.

5

As others have said, it's conventional to make them equivalent, as a convenience to users.

But for very popular web sites they're often not implemented the same way in DNS. Large sites generally use a content delivery network (CDN, such as Akamai or Cloudflare) to implement their services. This typically requires making the www name (and often other subdomains) a CNAME for the CDN's server name. But the apex of the site's domain can't be a CNAME, so redirecting this to the CDN must be done differently. The CDN might provide DNS service and host the domain, with the DNS server integrated into the CDN architecture so it provides the appropriate IP address. Another option is to point the apex to the IP of specific server(s), which send HTTP redirects to the www address that uses the CDN.

Apple is an example of this.

$ host www.apple.com
www.apple.com is an alias for www.apple.com.edgekey.net.
www.apple.com.edgekey.net is an alias for www.apple.com.edgekey.net.globalredir.akadns.net.
www.apple.com.edgekey.net.globalredir.akadns.net is an alias for e6858.dscx.akamaiedge.net.
e6858.dscx.akamaiedge.net has address 104.88.72.214
e6858.dscx.akamaiedge.net has IPv6 address 2600:1401:4000:5a6::1aca
e6858.dscx.akamaiedge.net has IPv6 address 2600:1401:4000:59c::1aca

edgekey.net, akadns.net, and akamaiedge.net are parts of the Akamai CDN service.

$ host apple.com
apple.com has address 17.253.144.10

17.253.144.10 is an Apple server. If you try to fetch a web page from this server, you get a redirect.

$ curl -D/dev/stdout -s apple.com
HTTP/1.1 301 Redirect
Date: Thu, 06 Oct 2022 14:00:47 GMT
Connection: close
Via: http/1.1 usbos3-edge-bx-006.ts.apple.com (acdn/167.13279)
Cache-Control: no-store
Location: https://www.apple.com/
Content-Type: text/html
Content-Language: en
X-Cache: none
CDNUUID: 01b82426-c712-4dd6-935e-de920112331f-1455864698
Content-Length: 304
2

Usually but not necessarily.

The internet and the domain name system predate the web.

It was the traditional practice to use a different subdomain for each service, this gave flexibility in hosting, the web server could be on a different machine to the ftp server which could be on a different machine to the irc server and so-on. The bare domain would often have no A record at all.

As the web became more and more dominant compared to other services it became common practice to offer web services on the bare domain. How exactly this was done varied, some sites simply offered the same pages on both hostnames, some sites redirected the bare domain to the www subdomain, some sites redirected the bare domain to the www subdomain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.