Pick one domain version — either www or non-www — and permanently redirect the other to it with a 301. To a browser, https://example.com and https://www.example.com look like the same site. To a search engine or an AI crawler, they are two different hostnames that can serve identical content, split your ranking signals, and duplicate every URL on your site. Canonicalizing to a single version is one of the cheapest, highest-leverage fixes in technical SEO.
Why two versions is a real problem
When both hostnames resolve and return a 200 status, every page effectively exists twice. Links, crawl attention, and citation signals get divided between the two copies. A page that would rank on its own strength now competes with its own twin, and neither version accumulates the full authority it deserves.
For AI answer engines the damage is subtler but just as costly. Retrieval systems deduplicate near-identical content, and when they encounter the same article under two hostnames they may pick the one you did not intend — or discount both as low-confidence duplicates. If the wrong version gets cited, your intended URLs quietly lose the attribution. Consolidating to one hostname removes that ambiguity and tells every machine exactly which address is the real one.
There is no SEO advantage to www over non-www or the reverse. The only thing that matters is that you choose one, apply it consistently everywhere, and never let the other version serve a live 200 response.
How to choose and enforce one version
Technically, the bare non-www domain is simpler and shorter, but on many DNS providers it cannot use a CNAME record at the apex, which occasionally matters for CDN setups. The www version sidesteps that limitation and gives you more flexibility with cookies across subdomains. For most sites the difference is negligible — pick whichever your brand already uses in print and marketing, then commit.
Enforcement happens at the server or CDN, and the rule is simple: the non-preferred hostname should issue a 301 permanent redirect to the preferred one, preserving the full path and query string. A request for www.example.com/blog/post must land on example.com/blog/post, not on the homepage. Redirecting everything to the root is a classic mistake that destroys deep links and confuses crawlers.
Do it in a single hop. A request that bounces from http-www to https-www to https non-www wastes crawl budget and slows real users. Combine the HTTPS upgrade and the hostname canonicalization so any variant reaches the final URL in one 301. Our guide to HTTP status codes and redirects explains why chains hurt and how to collapse them.
Back it up with canonical tags and consistent internal links
The 301 redirect is your primary signal, but reinforce it. Every page should carry a self-referencing canonical tag pointing at the preferred hostname, so even if a stray link or a cached copy surfaces the wrong version, the page itself declares its true address. This is exactly the pattern described in our canonical URLs and duplicate content guide — the redirect and the canonical tag should always agree.
Then audit your own house. Internal links, sitemap entries, hreflang annotations, and hardcoded asset URLs should all use the chosen hostname. If your navigation links to www but your canonical says non-www, you are sending mixed messages and forcing crawlers to follow a redirect on every internal click. Clean, consistent URLs also make your URL structure easier for machines to trust.
Verify the fix actually works
Do not assume the redirect is correct — test it. Request all four combinations: http and https, each with and without www. Every one should end at the same final https preferred-hostname URL, with a single 301 in the chain and a 200 at the destination. A quick command-line check with a tool that follows redirects will show you the exact hop sequence.
Check your XML sitemap next: it must list only preferred-hostname URLs, because listing a URL that immediately redirects wastes the crawler's time. Finally, watch your logs and Search Console for a week or two after the change to confirm bots are settling on the canonical version and that no important page started returning the wrong status. Getting this right is exactly the kind of foundational hygiene that keeps your HTTPS setup and ranking signals clean.
Not sure which hostname your site is actually serving, or whether your redirects chain? Run the CheckMy.site scanner to see how crawlers and AI bots resolve your domain, spot duplicate hostnames, and catch redirect chains before they cost you citations.