Skip to content

www and non-www canonicalization

mediumseo-www-canonicalizationreviewed

example.com and www.example.com are two hosts to a browser and to Google. Why both serving the site splits your signals, and how to pick one.

What it is

This check takes the host you entered, works out its counterpart — adding www. or removing it — and requests that. If the counterpart answers without redirecting to the host you entered, both are serving the site independently.

When the counterpart does not resolve at all, the check skips rather than fails. A domain with exactly one host serving it has already achieved what this check is asking for.

Why it matters

To a browser, and to a search engine, www.example.com and example.com are different hosts that happen to look similar. Two hosts serving identical content is duplicate content: links, rankings and crawl budget divide between two addresses instead of accumulating at one.

Which one you pick genuinely does not matter — there is no ranking advantage either way, and anyone who tells you otherwise is selling something. What matters is that one of them redirects to the other permanently, with a 301, so the choice is unambiguous and the redirect is cacheable.

How to fix it

nginx
server {
  listen 443 ssl;
  server_name www.example.com;
  return 301 https://example.com$request_uri;
}
.htaccess
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
_redirects
https://www.example.com/*  https://example.com/:splat  301!

Related checks

4
lowCanonical tagA canonical tag (<link rel="canonical">) declares a page's preferred URL when the same content is reachable at more than one address — with and without a trailing slash, with and without a tracking query string, over http and https.criticalHTTPSThis check reads the scheme of the URL that was scanned and fails when it is http rather than https. It is the first security check to run, and when it fails the rest are skipped — there is no useful question to ask about a Content-Security-Policy header on a connection anyone can rewrite in transit.lowXML sitemapAn XML sitemap is a file listing the URLs on a site that its owner considers worth indexing, optionally with the date each was last modified. This check requests /sitemap.xml and asks whether the server returns it.lowCustom 404 pageThis check requests a path that cannot exist — a generated one, so it is not something a site could special-case — and looks at two things: the status code that comes back, and how much content came with it. A response that is not 404, or is under a couple of hundred bytes, reads as a server default rather than a page anyone designed.

This is one of the 75 checks the scanner runs. See what we check for the full list, every severity weight, and how the score is computed from them.

See whether your own site passes www and non-www canonicalization.

One page, all 75 checks, free. No account, no card.

Check this on my site