www vs non-www: which should your site use?
Kofi Agyem, Founder and CEO, CloudzyroPublished · 5 min read
On this page
Should your site be www.example.com or example.com? Neither is better for SEO. What actually differs, how to pick one and how to redirect the other.
1. The short answer
Neither www nor non-www is better for search engines or visitors. What matters is picking one as your main address and permanently redirecting the other to it. The practical differences are technical: www can be pointed with a CNAME record, which most hosts and CDNs prefer, and it keeps cookies away from other subdomains. The bare domain is shorter.
www.example.com is technically a subdomain of example.com, the bare domain (also called the apex or root domain). They're two different names, so each needs its own DNS record, and only one should show your site directly.
2. Why you must choose one
If both addresses show your site without a redirect, search engines see two copies of every page. They'll usually pick one themselves, but links people share get split between the two, analytics shows two hosts, and visitors may sign in on one and appear signed out on the other.
The fix is the same whichever you choose: a permanent redirect (HTTP 301 or 308) from the one you don't use to the one you do, keeping the rest of the address, plus a canonical tag on each page pointing to the main address.
3. The real differences
- DNS flexibility (www wins).
wwwcan be a CNAME, so your host can change its servers without you changing anything. The bare domain can't be a CNAME in standard DNS, because it also holds the domain's NS, SOA and usually MX records. It needs an A record or a provider that offers ALIAS, ANAME or flattening. See A record vs CNAME. - Cookies (www wins). A cookie set for the whole of the bare domain is sent to every subdomain, including
blog.orshop.on other platforms. Serving your site onwwwkeeps its cookies there. - Length (bare wins). It's four characters shorter, and looks cleaner on a business card.
- Habit (a draw). Some browsers hide
wwwin the address bar anyway, and people find both.
In short: pick the bare domain if you like it and your DNS provider supports flattening; pick www if you want the setup that works with any DNS provider.
4. How Cloudzyro handles it
On Cloudzyro Sites & Apps, www is the main address by default, because it works with every DNS provider:
Type Name Value
CNAME www domains.cloudzyro.app
A @ 173.234.137.167The A record on the bare domain points to a server whose only job is to forward visitors to https://www.yourdomain.com over HTTPS with a permanent redirect, keeping the rest of the address. Certificates for both are automatic.
Prefer the bare domain as your main address? Add example.com to the site directly and point it with a CNAME, ALIAS, ANAME or flattened record to domains.cloudzyro.app. That works at Cloudflare, Namecheap, Porkbun, Squarespace Domains, DNSimple, DNS Made Easy, easyDNS, Gandi and DreamHost. Details in Connect a custom domain.
Domains bought in Cloudzyro Domains and pointed at a site get both records set for you, with www as the main address. Full steps for any domain: How to point your domain at your site.
5. A worked example: switching to www
Sam's site has always been at samdesigns.com, and she's moving it to a host that prefers www. To switch without losing anything:
- Add
www.samdesigns.comto the new host and pointwwwat it with the CNAME it gives. - Point the bare domain at the host's redirect, so
samdesigns.com/workgoes tohttps://www.samdesigns.com/workwith a 301. - Update the site's canonical tags, sitemap and any absolute links to use
https://www.samdesigns.com. - If she uses Google Search Console, check that the
wwwversion is covered (a Domain property covers both). - Leave the redirect in place for good. Old links keep working.
6. Which should you pick?
- Starting fresh, any DNS provider:
www. It works everywhere and keeps your options open. - Starting fresh, DNS at Cloudflare or another provider with flattening: whichever you prefer. The bare domain looks cleaner.
- An existing site: keep what you have. Switching works, but there's no benefit worth the effort unless you're changing hosts anyway.
- Lots of subdomains on other platforms (shop, help, app):
www, so your main site's cookies stay on it.
7. HTTPS, HSTS and the redirect
The redirect itself needs HTTPS on both names: someone typing https://example.com must get a valid certificate before they can be sent to https://www.example.com. Make sure your host covers both.
HSTS is a header that tells browsers to only ever use HTTPS for your site. If you send it with includeSubDomains from the bare domain, it applies to every subdomain too, so every one of them must have HTTPS working first. Start without includeSubDomains, or with a short max-age, until you're sure.
8. Common mistakes
- No record for one of them. Visitors who type the other version get an error. Make sure both names resolve.
- A temporary redirect. A 302 tells search engines the move might not last. Use 301 or 308.
- Redirecting to the home page.
example.com/menushould go towww.example.com/menu, not the home page. - HTTPS on only one name. Each name needs a valid certificate, or browsers warn before the redirect can happen.
- Redirect loops. The host redirects www to bare while a CDN or plugin redirects bare to www. Choose one place to set the rule.
- Canonical tags pointing at the wrong one. They should match the address you chose.
9. How to check yours
curl -I shows the status code and where a redirect goes, without loading the page:
curl -I http://example.com
curl -I https://example.com
curl -I https://www.example.com
# And the DNS records behind them
dig +short example.com
dig +short www.example.comYou want one address to answer 200 and the others to answer 301 (or 308) with a location: header pointing at it, keeping the path. If a name returns nothing in dig, it has no record yet. If your domain is on a Cloudzyro site and isn't working, see Domain not working.