For years, a small pedantry war has been raging in our address bars. In one corner are brands like Google, Instagram, and Facebook. This group has chosen to redirect
www.example.com. In the opposite corner: GitHub, DuckDuckGo, and Discord. This group has chosen to do the reverse and redirect
Does “WWW” belong in a URL? Some developers hold strong opinions on the subject. We’ll explore arguments for and against it after a bit of history.
What’s with the Ws?
The three Ws stand for “World Wide Web”, a late-1980s invention that introduced the world to browsers and websites. The practice of using “WWW” stems from a tradition of naming subdomains after the type of service they provide:
- a web server at www.example.com
- an FTP server at ftp.example.com
- an IRC server at irc.example.com
WWW-less domain concern 1: Leaking cookies to subdomains
Critics of “WWW-less” domains have pointed out that in certain situations, subdomain.example.com would be able to read cookies set by example.com. This may be undesirable if, for example, you are a web hosting provider that lets clients operate subdomains on your domain. While the concern is valid, the behavior was specific to Internet Explorer.
RFC 6265 standardizes how browsers treat cookies and explicitly calls out this behavior as incorrect.
Another potential source of leaks is the
Domain value of any cookies set by example.com. If the
Domain value is explicitly set to example.com, the cookies will also be exposed to its subdomains.
|Cookie value||Exposed to example.com||Exposed to subdomain.example.com|
In conclusion, as long as you don’t explicitly set a
Domain value and your users don’t use Internet Explorer, no cookie leaks should occur.
WWW-less domain concern 2: DNS headaches
Sometimes, a “WWW-less” domain may complicate your Domain Name System (DNS) setup.
When a user types example.com into their browser’s address bar, the browser needs to know the Internet Protocol (IP) address of the web server they’re trying to visit. The browser requests this IP address from your domain’s nameservers – usually indirectly through the DNS servers of the user’s Internet Service Provider (ISP). If your nameservers are configured to respond with an A record containing the IP address, a “WWW-less” domain will work fine.
In some cases, you may want to instead use a Canonical Name (CNAME) record for your website. Such a record can declare that www.example.com is an alias of example123.somecdnprovider.com, which tells the user’s browser to instead look up the IP address of example123.somecdnprovider.com and send the HTTP request there.
Notice that the example above used a WWW subdomain. It’s not possible to define a CNAME record for example.com. As per RFC 1912, CNAME records cannot coexist with other records. If you tried to define a CNAME record for example.com, a MX (Mail Exchanger) record for example.com would not be allowed to exist. As a result, it would not be possible to accept mail on @example.com.
Some DNS providers will allow you to work around this limitation. Cloudflare calls their solution CNAME flattening. With this technique, domain administrators configure a CNAME record, but their nameservers will expose an A record.
For instance, if the administrator configures a CNAME record for example.com pointing to example123.somecdnprovider.com, and an A record for example123.somecdnprovider.com exists pointing to 188.8.131.52, then Cloudflare would expose an A record for example.com pointing to 184.108.40.206.
In conclusion, while the concern is valid for domain owners who wish to use CNAME records, certain DNS providers now offer a suitable workaround.
Most of the arguments against WWW are practical or cosmetic. “No-WWW” advocates have argued that it’s easier to say and type example.com than www.example.com (which may be less confusing for less tech-savvy users).
Opponents of the WWW subdomain have also pointed out that dropping it comes with a humble performance advantage. Website owners could shave 4 bytes off each HTTP request by doing so. While these savings could add up for high-traffic websites like Facebook, bandwidth generally isn’t a scarce resource.
One practical argument in favor of WWW is in situations with newer top-level domains. For example, www.example.miami is immediately recognizable as a web address when example.miami isn’t. This is less of a concern for sites that have recognizable top-level domains like .com.
Impact on your search engine ranking
The current consensus is that your choice does not influence your search engine performance. If you wish to migrate from one to the other, you’ll want to configure permanent redirects (HTTP 301) instead of temporary ones (HTTP 302). Permanent redirects ensure that the SEO value of your old URLs transfers to the new ones.
Tips for supporting both
Sites typically pick either example.com or www.example.com as their official website and configure HTTP 301 redirects for the other. In theory, it is possible to support both www.example.com and example.com. In practice, the costs may outweigh the benefits.
From a technical perspective, you’ll want to verify that your tech stack can handle it. Your content management system (CMS) or statically generated site would have to output internal links as relative URLs to preserve the visitor’s preferred hostname. Your analytics tools may log traffic to both hostnames separately unless you can configure the hostnames as aliases.
Lastly, you’ll need to take an extra step to safeguard your search engine performance. Google will consider the “WWW” and “non-WWW” versions of a URL to be duplicate content. To deduplicate content in its search index, Google will display whichever of the two it thinks the user will prefer – for better or worse.
To preserve control over how you appear in Google, it recommends inserting canonical link tags. First, decide which hostname will be the official (canonical) one.
For example, if you pick www.example.com, you will have to insert the following snippet in the
<head> tag on https://example.com/my-article:
<link href="https://www.example.com/my-article" rel="canonical">
This snippet indicates to Google that the “WWW-less” variant represents the same content. In general, Google will prefer the version you’ve marked as canonical in search results, which would be the “WWW” variant in this example.
Despite intense campaigning on either side, both approaches remain valid as long as you are aware of the benefits and limitations. To cover all your bases, be sure to set up permanent redirects from one to the other and you’re all set.
The author selected the Open Internet/Free Speech Fund to receive a donation as part of the Write for DOnations program.
I found this part slightly confusing:
In this case the CNAME record would be served by the nameserver for example.com, while the NS records would be served by the .com nameserver I believe?
Perhaps a clearer example I think would be if example.com’s nameserver served a CNAME record for the root, and MX records as well, which would be against the DNS spec.
You are correct, Benjamin. Thank you for the suggestion!
Actually, you cannot have CNAME records for the base domain in any case, because the base domain always has an SOA record. So even without MX records, it is never possible to set a CNAME for the base domain.
I am thinking the same, there are some benefits but the idea has died some years ago, still for subdomains I think locales like en, de are the best.
Great article, thank you.
Years ago, didn’t Paul who pushed for WWW regret for forcing it on to the standard? (It’s very possible I’m wrong!)
Clearly the public (the main users of the inet) doesn’t care for or understand WWW, while having a little more understanding of Subdomain.XZY.com, though not much more.
A minor quibble, isn’t “a late-1980s invention” a bit early given the first web server and browsers were released in 1991?
I suppose it depends on when you consider a technology to be invented. It’s true that the general public did not get to experience the Web until 1991. The article uses Berners-Lee’s first proposal as a reference point, which dates back to 1989.
The “www” helps show that it is infact a URL. I would guess that grandparents or less tech savvy users are confused about .co, .biz, .hotdog, .etc urls and keeping the www makes non-.com domains clearer.
I’ve chosen not to use it purely for aesthetics really