www vs non-www: pick one, and don't let two layers fight over it.
Search engines treat www and the bare domain as two sites. The fix is simple; the classic mistake is fixing it twice, in opposite directions.
Search engines see https://example.com and https://www.example.com as two different sites unless you tell them otherwise. The standard fix is one permanent redirect. The standard mistake is adding a second redirect, in the opposite direction, somewhere else.
What Google actually wants
Google's canonicalization guidance is clear: pick a preferred version of each URL, redirect the others to it with a permanent redirect, and signal the same choice everywhere else, in rel="canonical" tags, in your sitemap and in internal links. Mixed signals don't get you penalised, but they leave Google to choose for you, and it may not choose the version you link to.
There is no ranking advantage to www or to the bare domain. Large sites use both. The only technical difference is that a bare domain can't be a DNS CNAME at many providers, which is one reason hosting platforms often recommend www as the primary.
How the loop happens
Modern hosts and CDNs handle this for you. On platforms like Vercel, Netlify and Render you attach both hostnames to a project, choose one as primary, and the platform redirects the other at the edge, before your application ever sees the request.
The loop appears when someone also handles it in the application, in the other direction. A typical sequence:
- The platform is set to serve www as primary, so it redirects example.com to www.example.com.
- A developer, seeing canonical tags that say example.com, adds middleware that redirects www to the bare domain.
- The browser goes bare → www → bare → www until it gives up with "too many redirects" (ERR_TOO_MANY_REDIRECTS in Chrome).
Each redirect is correct in isolation. Together they take the site down. Cloudflare documents a cousin of this problem: with its "Flexible" SSL mode, Cloudflare talks to your server over HTTP, your server redirects to HTTPS, Cloudflare requests HTTP again, and the loop never ends. Same root cause: two layers that each think they own the decision.
The setup that doesn't break
- Choose the primary host where the domain is configured, at your hosting platform or CDN, and let it redirect the other host with a single 301 or 308.
- Make the application agree. Store the canonical origin in one config value and use it for canonical tags, og:url, structured data, the sitemap, robots.txt, emails and IndexNow pings. Nothing should hard-code the other host.
- Close the side doors. Platform default hostnames, such as a project's *.vercel.app or *.onrender.com address, serve a full copy of your site. Redirect those to the canonical host too, with a rule that only matches that hostname so it can never fight the main redirect.
Check yours in two minutes
curl -sI https://example.com
curl -sI https://www.example.com
One should return 200. The other should return a single 301 or 308 whose Location header points at the first. A redirect pointing back where you started means a loop. Two 200s mean a duplicate site.
Then open a few pages and check that the canonical tag uses the host that returned 200. Mismatched canonicals are the quiet version of the same problem: no outage, just Google picking a version for you.
Questions people ask
Should I use www or non-www for SEO?
Either works. Pick one, redirect the other to it with a single permanent redirect, and use the same host in every canonical tag, your sitemap and your internal links.
What causes "too many redirects" after adding a www redirect?
Usually two layers redirecting in opposite directions, typically the host or CDN and the application. Remove one of them so only a single layer decides the hostname.
Does having both www and non-www live hurt SEO?
It splits signals across two copies and leaves Google to choose the canonical. A clean redirect plus matching canonical tags fixes it.
Want this mapped onto your product?
See how our SEO work runs, or send your store link and a founder will reply personally.