Skip to content
Cloudzyro
Domains and DNS

www vs non-www: which should your site use?

Kofi Agyem

, Founder and CEO, CloudzyroPublished · 5 min read

On this page
  1. 1. The short answer
  2. 2. Why you must choose one
  3. 3. The real differences
  4. 4. How Cloudzyro handles it
  5. 5. A worked example: switching to www
  6. 6. Which should you pick?
  7. 7. HTTPS, HSTS and the redirect
  8. 8. Common mistakes
  9. 9. How to check yours
  10. 10. Sources and further reading

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). www can 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. or shop. on other platforms. Serving your site on www keeps its cookies there.
  • Length (bare wins). It's four characters shorter, and looks cleaner on a business card.
  • Habit (a draw). Some browsers hide www in 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.167

The 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:

  1. Add www.samdesigns.com to the new host and point www at it with the CNAME it gives.
  2. Point the bare domain at the host's redirect, so samdesigns.com/work goes to https://www.samdesigns.com/work with a 301.
  3. Update the site's canonical tags, sitemap and any absolute links to use https://www.samdesigns.com.
  4. If she uses Google Search Console, check that the www version is covered (a Domain property covers both).
  5. 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/menu should go to www.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.com

You 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.

10. Sources and further reading

Questions

Is www or non-www better for SEO?
Neither. Search engines treat them equally. What matters is choosing one and permanently redirecting the other to it, so links and rankings aren't split.
Do I still need www?
No. Browsers and visitors handle both. Many sites still use it for practical reasons, like being able to point it with a CNAME record.
Can I switch from www to non-www later?
Yes. Make the new one your main address, permanently redirect the old one to it with a 301, update your canonical tags and sitemap, and keep the redirect in place for good.
Why does my site work with www but not without it?
The bare domain has no DNS record pointing at your host, or nothing redirects it. Add an A record or a flattened record for the bare domain, as your host describes.
Does www need its own SSL certificate?
Both names need to be covered, either by one certificate listing both or by separate ones. Most hosts handle this automatically.
Does the bare domain need its own DNS record?
Yes. www and the bare domain are separate names in DNS. Each needs a record, even if the bare domain's only job is to forward visitors to www.
Which do big websites use?
Both are common. Some well-known sites use www and others use the bare domain. It's a matter of preference and setup, not quality.

Put your site online free

From your AI tool, Git or a zip, with every version kept.