All posts
·8 min read·technical seo · canonical urls · redirects

One homepage, four addresses: canonical tags and the www redirect Google wants to agree

Get Google to index the homepage you chose. Make your www redirect, canonical tag, sitemap, and internal links name one URL, and stop Google from picking for you.

Type example.com into a browser and it loads. So do www.example.com, http://example.com, and https://www.example.com. To you, that is one homepage. To Google, it is four URLs that need sorting out before any of them can rank. Your redirects and your canonical tag are the two loudest ways to tell Google which one is real. When they agree, the sorting is easy. When they point at different addresses, Google picks for you, and it does not always pick the one you would.

Why one homepage has four addresses

Every website sits at the intersection of two choices: protocol (http or https) and hostname (with www or without). Multiply them and you get four origins:

http://example.com
http://www.example.com
https://example.com
https://www.example.com

Each one is a separate URL to a crawler. If all four return a 200, you have four copies of the same page competing with each other, and links to the "wrong" version split your signals instead of adding them up.

The count goes up from there. /index.html, /index.php, tracking parameters like ?utm_source=newsletter, and mixed-case paths all create more duplicates. One thing that does not: the trailing slash on the homepage itself. https://example.com and https://example.com/ are the same request, because a browser always asks the server for /. Deeper pages are different. /services and /services/ are two distinct URLs, and your site should commit to one form.

What a canonical tag actually tells Google

A canonical tag is a single line in the <head> of a page that names the preferred URL for that content:

<link rel="canonical" href="https://www.example.com/" />

The canonical link relation is defined in RFC 6596, and the key word in that spec is "preferred." It is a hint, not a command. Google's documentation on consolidating duplicate URLs lists the signals it weighs when choosing a canonical:

  • Redirects are a strong signal that the redirect target should be canonical.
  • The canonical tag is a strong signal for the URL it names.
  • Sitemap inclusion is a weak signal.

Google also prefers HTTPS over HTTP when nothing else conflicts, and it weighs other signals, including how your own pages link to each other.

Two of those signals are strong. If your server redirects everything to www while your canonical tag names the bare domain, you have sent two strong signals pointing in opposite directions. Google has to break the tie on its own, and it may break it differently on different pages.

You can see the result in Google Search Console. The URL Inspection tool shows a "User-declared canonical" (what your tag says) and a "Google-selected canonical" (what Google decided). When they differ, Google has overruled you, usually because something else on your site disagreed with your tag.

Where the canonical tag and the redirect stop agreeing

Mixed signals build up when the redirect lives in one layer (DNS, CDN, or hosting) and the canonical tag lives in another (your CMS or theme), configured by different people at different times. The common patterns:

  1. The CMS thinks it lives somewhere else. The host redirects to www, but the CMS's own site URL setting still says the bare domain, so every canonical tag, sitemap entry, and generated link uses the version that redirects.
  2. A leftover http:// canonical. The site moved to HTTPS years ago, but a hardcoded canonical in the theme still says http://. Every page now names a URL that redirects away from itself.
  3. Every page canonicalizes to the homepage. A template bug puts the homepage URL into the canonical tag site-wide. That tells Google your service pages, blog posts, and contact page are all duplicates of the homepage.
  4. A staging host in production. A site built on staging.example.com or a platform preview domain ships with that hostname still in the canonical tag.
  5. Two canonical tags. An SEO plugin adds one and the theme adds another. If they name different URLs, Google may ignore both.
  6. A sitemap on a different version. The sitemap lists https://example.com/... while redirects and canonicals point at www. A weak signal, but still noise.

The rule underneath all six: a canonical tag should name a URL that returns a 200 directly. If the URL in your tag redirects, 404s, or is blocked from crawling, the tag is working against you.

The handshake that runs before your redirect

There is one failure no canonical tag can fix, because it happens before any HTML loads.

A redirect only runs once the browser reaches the hostname it was given. Two things have to be true for each of your four addresses:

  • DNS has to resolve it. If www.example.com has no DNS record, that version doesn't redirect. It simply fails. Plenty of sites have a working bare domain and a dead www, or the reverse.
  • The SSL certificate has to cover it. The TLS handshake happens before the server sends a single HTTP header. If your certificate lists only www.example.com and someone visits https://example.com, they get a certificate warning, and the redirect you configured never gets a chance to run.

Test both hostnames separately, not just the one you type every day. If you use HSTS, the browser upgrades http:// to https:// internally, which saves a hop but makes certificate coverage even more important. The HSTS guide covers how to roll that out without locking anyone out.

www or bare domain: does it matter which?

For rankings, no. Either one works as a canonical. What matters is that you pick one and stay with it.

One practical difference: DNS rules don't allow a CNAME record at the bare domain, because the apex already holds SOA and NS records and a CNAME can't coexist with other records. If your host asks you to point a CNAME at their platform, www is the simpler fit. Many DNS providers work around the limit with ALIAS or flattened records, so the bare domain is still a valid choice.

Whichever you choose, don't flip it later. Every switch makes Google consolidate your signals all over again.

How to make every signal name the same URL

Once you have picked the version, line up every signal behind it:

  • One redirect, one hop. Each of the three non-canonical origins should 301 straight to the final URL, with protocol and hostname fixed in a single step. http://example.com goes directly to https://www.example.com/, not through https://example.com first.
  • A self-referencing canonical on every page. Each page's tag names its own canonical URL, absolute, with the chosen protocol and hostname. Google recommends absolute URLs over relative ones here.
  • CMS site URL matches the redirect target. On most platforms this one setting drives canonicals, sitemaps, and internal links. Fix it first.
  • Sitemap lists canonical URLs only. No redirecting URLs, no alternate hostnames.
  • Internal links use the final form. Navigation, footer, and in-body links should never pass through a redirect.
  • Metadata agrees too. og:url, structured data url fields, and hreflang annotations should all name the same version.

How to check your own homepage

Start with curl, which prints every hop for each of the four addresses:

for u in http://example.com http://www.example.com https://example.com https://www.example.com; do
  echo "== $u"
  curl -sIL "$u" | grep -iE "^(HTTP|location)"
done

All four should end on the same final URL with a 200, and the three that redirect should get there in one hop. Then confirm the tag on the final page:

curl -sL https://www.example.com/ | grep -io '<link[^>]*rel="canonical"[^>]*>'

That should print exactly one line, naming the same URL the redirects landed on.

If you'd rather not read curl output, the redirect checker traces every hop for a URL with its status code and destination, so you can compare where all four variants end up. Run the SSL check against both the www and bare hostnames to confirm the certificate covers each one. For the whole picture, a full scan from the AcuityScan homepage runs 350+ checks across 8 modules, including whether your page declares a canonical tag, whether your HTTP to HTTPS redirect is permanent, and how your SSL certificate is set up, with a plain-English fix for each finding.

TL;DR

  • Protocol and hostname combine into four addresses for one homepage, and each one is a separate URL to a crawler.
  • Redirects and canonical tags are both strong signals. When they disagree, Google chooses the canonical for you.
  • DNS and SSL have to cover all four addresses, or the redirect never runs.
  • www versus bare domain doesn't matter for rankings. Consistency does.
  • Point redirects, canonicals, sitemap, internal links, and metadata at one URL, then verify with curl or a redirect trace.

Scan your own site

See what 350+ checks find on your domain.

Free, no signup, 60 seconds. Email auth · DNS · SSL · Performance · SEO · Accessibility · Privacy · Mobile.