www vs non-www: which to use, and how to redirect the other
Either works for visitors and for search. What matters is choosing one as the site's real address and permanently redirecting the other to it. The choice is usually made by DNS: www can point anywhere with a CNAME, while the bare domain can't hold one, so many hosts find www easier to connect.
The technical difference
www.example.com is a subdomain like any other. example.com on its own is the zone's apex, which must carry the domain's SOA and NS records and usually its MX and TXT records too. RFC 1034 says that if a CNAME is present at a name, no other data should be present there. So the apex can't be a CNAME, and a host that gives you a CNAME target can only be reached at the apex if your DNS provider offers a workaround, usually called CNAME flattening or an ALIAS record, which looks up the target and answers with its addresses.
That one rule explains most of the trade-off. With www, you add a CNAME and the host can move its servers whenever it likes. With the bare domain, you either need a DNS provider that flattens, or fixed A records that you'll have to update if the host's addresses change.
Choosing between them
| www.example.com | example.com | |
|---|---|---|
| DNS setup | A CNAME at any DNS provider | Needs flattening/ALIAS, or A records |
| Look | Longer, familiar, clearly a web address | Shorter, cleaner on print and screens |
| Cookies | Cookies set on www stay on www | Cookies set on the apex can be sent to every subdomain |
| Search | No ranking difference | No ranking difference |
| Typical fit | Hosts that give you a CNAME target; larger sites with many subdomains | Short brands where the DNS provider supports flattening |
If you've already published one form for a while, keep it. Switching later works, but it means a site-wide redirect and some time while search engines settle on the new address.
Redirect the other form
- Decide the canonical host, for example
www.example.com. - Connect that host to your website and confirm it loads over HTTPS.
- Point the other form somewhere that redirects. Many DNS providers and registrars offer a redirect or forwarding rule: set
example.comto forward tohttps://www.example.comwith the path kept. - Make it permanent. Use a 301 or 308. Google's redirects guide explains that permanent redirects tell it the target should be the canonical address.
- Cover HTTPS on both. The redirecting form needs its own certificate, or browsers will warn before the redirect happens. Check your forwarding service provides one.
- Use the canonical form everywhere you control: internal links, sitemaps, email signatures, social profiles, business listings.
What happens if you don't choose
If both forms serve the same pages without a redirect, you have two copies of the site. Google's guide to consolidating duplicate URLs describes how it picks one as canonical from signals such as redirects, canonical tags and sitemaps; redirects are the strongest. Without one, it guesses, links and shares are split between two addresses, and analytics may count them separately. Visitors notice nothing, which is why the problem often goes unfixed for years.
Check it worked
- Run
curl -sI http://example.comandcurl -sI https://example.com. Each should answer301or308with alocationheader pointing to the canonical form. - Try a deep link on the non-canonical form, such as
/contact. It should land on the same path, not the home page. - Open both forms in a private window and confirm there's no certificate warning before the redirect.
- Check the page source on the canonical form: links and any
rel="canonical"tag should use the same host.
Common mistakes
- A temporary (302) redirect left in place for good. Use a permanent one.
- Forwarding that drops the path, sending every old link to the home page.
- Masked or framed forwarding, which shows the other address in the bar while loading the site in a frame. Many sites refuse to be framed, and it hides the real address.
- Replacing apex MX records while setting up the redirect, which breaks email.
www vs non-www on Anticode
Anticode connects the hostnames you add, on paid plans, using a CNAME and sometimes a TXT record, with certificates issued automatically. www or another subdomain is the straightforward choice. The bare domain works only if your DNS provider supports CNAME flattening or ALIAS records. Anticode doesn't redirect one form to the other for you: set the redirect for the other form at your DNS provider or registrar if they offer one. See connect a custom domain and CNAME vs A record.
Questions people ask
Is www or non-www better for SEO?
Neither. Search engines treat them as two hostnames; what matters is choosing one and redirecting the other permanently.
Can I switch later?
Yes. Connect the new form, redirect the old one permanently path by path, and update your links and sitemap. Expect a period while search engines move to the new address.
Do I still need the other form at all?
Yes. People type both, and old links may use either. Keep the other form registered and redirecting.