Blog
3 min read

www vs non-www: Which Should Your Website Use?

example.com or www.example.com? What the difference actually is, why it doesn't matter for SEO as long as you pick one, how to redirect the other, the DNS catch with root domains, and the cookie consideration that makes some teams choose www.

Should your site be example.com or www.example.com? People argue about this more than it deserves. The short answer: either is fine, as long as you choose one and redirect the other to it. The details explain why — and the one situation where www has a real technical edge.

They're technically different addresses

www is just a subdomain — the same kind of thing as blog.example.com. The version without it is called the root, apex or naked domain.

Because they're different hostnames, browsers and search engines treat example.com and www.example.com as two separate sites unless you tell them otherwise. If both serve your site without redirecting, Google may see duplicate content, and your links and analytics get split between two versions.

Rule one: pick one, redirect the other

Choose your canonical version — the one you want people to see. Then make the other permanently redirect to it with a 301 redirect, preserving the path:

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

All roads lead to one address, over HTTPS. Then:

  • use that version in your sitemap, internal links, and canonical tags,
  • make sure both names have SSL certificates (the redirect itself happens over HTTPS).

Test it by typing each variant into a browser. If any of them shows an error or doesn't land on your chosen version, fix it. (Redirect loops show up as ERR_TOO_MANY_REDIRECTS.)

For SEO, the choice doesn't matter

Google doesn't prefer one or the other. What matters is consistency: one version, with everything else redirecting to it. If you're starting fresh, pick whichever you like the look of — most new products choose the shorter non-www.

If your site has existed for years on one version, don't switch without a good reason; a migration means redirects and a temporary wobble in search traffic.

The DNS catch with root domains

Here's a technical difference. The DNS standard doesn't allow a CNAME record on the root domain. That matters because many hosting platforms ask you to point your domain at them with a CNAME (like your-app.hostingplatform.com), so they can change their servers' IP addresses without you updating anything.

  • www.example.com → CNAME → works anywhere.
  • example.com → CNAME → not allowed by the standard.

Solutions:

  • Use the host's A record IP address for the root, if they provide a stable one.
  • Use a DNS provider that supports ALIAS / ANAME records or "CNAME flattening", which behave like a CNAME at the root.
  • Or use www as your canonical and redirect the root to it.

See DNS records explained and how to connect a custom domain.

Cookies set for a root domain with a Domain=example.com attribute are sent to every subdomain too — blog.example.com, status.example.com, and anything on third-party services. Large sites sometimes choose www so the main site's cookies can be scoped to www.example.com only, keeping them away from other subdomains. For most small sites this doesn't matter, especially if your app lives on its own subdomain. (Cookies explained.)

Quick decision guide

  • New site, simple setup: non-www (example.com), with www redirecting to it — provided your DNS can point the root at your host.
  • Your host only gives you a CNAME and your DNS can't flatten it: www as canonical, root redirecting.
  • Big site with many subdomains and cookie concerns: www.
  • Existing site: keep what you have.

The summary

  • www and the root are different hostnames; without a redirect, they're two copies of your site.
  • Pick one, 301-redirect the other (and HTTP) to it, and use it consistently.
  • Google doesn't prefer either.
  • Root domains can't use CNAME records — use an A record, ALIAS/flattening, or choose www.

EasySpawn tells you exactly which DNS records to add when you connect your own domain, and issues SSL automatically once they resolve — and Claude Code can set up the redirect to your chosen version and test every variant. See how it works or join the waitlist.

Related: What Is a Domain Name? · Subdomain vs Subdirectory · HTTP Status Codes Explained · How Automatic SSL Actually Works

Keep reading