Whenever possible, use a single domain & subdomain # matchurl

Whenever possible, use a single domain & subdomain # matchurl

06.Oct.2021

Web developers and SEOs can be a contentious lot. Everyone has an opinion on what one should or shouldn't do, but there is a right way to do things -- and it's probably not the way you've been told before. 

In this article I'll be talking about something as simple as whether you should use www.example.com or example.com . In reality, they're both exactly the same domain -- with exactly the same content that you want ranked by search engines -- but if you don't know some of the lesser-known rules governing how domain names work you might place yourself at a disadvantage in search engine rankings for no good reason whatsoever. For most webmasters, having a single site means using either www or non-www (with it redirecting to the other). There's nothing particularly wrong with this, but here are some interesting facts you might not know regarding how search engines treat both:

What You Know Probably Isn't True

First of all, if your site is www.example.com , Google will still index example.com despite the fact that your site isn't reachable at that address (because of the 301 redirect). Also, Google has confirmed that you don't need to use both addresses and can opt to just one or the other -- though it does prefer that you use www . I've also seen information suggesting that Google may ignore non-www entirely , so I recommend using www if possible. According to our own webmaster surveys , a majority of users prefer to use www, especially on ecommerce sites.

Some have suggested that subdomains are treated as separate entities from their parent domain, so Google would index products.example.com separately from example.com even though they share the same content . I've also seen some people suggest that using a subdomain might hurt your search rankings because it's not as "trustworthy" as a root domain -- but this is nonsense and doesn't take into account how different browsers handle sub- vs. root- domains differently (for more information please read Understanding Domain Trust ) -- or that having separate servers for each subdomain means you're now managing multiple domains/hosts instead of one...which can make things very complex indeed if you want to do things right.

Although the SEO world is full of opinions that are frequently wrong (and frequently believed thanks to sloppy research and confirmation bias), this particular bit of misinformation seems to stem from a now-deleted entry on Google's own developer site . This old page suggested that subdomains were "potentially" treated separately by Google, but it went on to say:

There's no easy way to determine this for your site; you'll need to make some webmaster tools requests and see what information you find. [...] We may publish additional documentation about our indexing system in the future; when we do, we will announce it on our blog.

I'm not sure why they deleted this page, because Google's knowledge base contains many articles suggesting that subdomains are treated like their parent domain (for example). They even go so far as to recommend not using separate servers for each subdomain, which seems to suggest they do share the same ranking ability.

If you want to be extra careful, I suppose it's okay to use www and non-www because it doesn't really hurt anything either way. But if you only have one site then there's no real reason not to just use www .

Other than that, the one thing people tend to get confused about is whether or not your site should display a "default" document when someone visits http://example.com/something . This blog does, but Google makes this pretty clear in its documentation:

 

In general, you should not create a default document for your root directory. This is because when somebody requests http://example.com/ , they'll get the same content as somebody who requests http://example.com/index.html . In other words, there's no point in setting up a default document unless it is different from your index file.

A common reason developers do this is to eliminate "duplicate content" warnings from search engines...but, again, this seems to be a no-op since Google specifically recommends against doing so:

If you want to use the same homepage on both your root domain and www subdomain, we recommend using server-side 301 redirects or Apache mod_rewrite [...].

In short: You can either have a default document or a 301, pick one. Don't have both.

I think the reason why many developers (and even some SEOs) get confused about this is that they're more concerned with what "feels right" than what's actually faster and more efficient for users and search engines alike. If you want to keep all your content on one host/domain then use www , if you don't care which you use then go with non-www . But there's really no good reason to go overboard and create two hosts/domains when using two will make things more complex and confusing for everyone involved.

 

We are social