Neither is better for search. Google treats www.example.com and example.com as two separate hostnames, so what matters is choosing one, redirecting the other to it with a 301 redirect, and using the chosen address everywhere. Choose www for more flexible DNS and CDN setup, or non-www for shorter, cleaner addresses.
Why it matters
If both versions of your site load, search engines may see two copies of every page. Links, shares and bookmarks get split between them, and reports in Google Search Console become harder to read. A single chosen host keeps every signal pointing at one address.
How to decide
- List where you will use the address: business cards, email signatures, social profiles and advertising. A short bare domain looks tidy in print.
- Check your DNS provider. A bare domain (also called the apex or root) usually cannot use a standard CNAME record, so some hosts need an ALIAS, ANAME or "CNAME flattening" feature. A www hostname can use a plain CNAME to point at a host or CDN.
- Consider cookies. Cookies set on a bare domain can be sent to every subdomain, while a www hostname lets you keep cookies away from static or API subdomains.
- Pick one and write it down as your canonical host. Both choices are fine, so do not spend more time than this on it.
- Redirect the other version to the chosen one with a permanent 301 redirect, for example in nginx:
server {
listen 443 ssl;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
- Make sure your HTTPS certificate covers both hostnames, otherwise visitors who type the redirected version see a browser warning before the redirect can happen.
- Update canonical tags, sitemap URLs, internal links and your Search Console property to use the chosen host.
Common mistakes
- Letting both versions return a normal page with no redirect.
- Redirecting only the home page, so deep pages such as /pricing still answer on both hosts.
- Switching hosts later without a 301 redirect for every URL.
- Using the chosen host in the sitemap but the other host in canonical tags.
- Forgetting the certificate for the redirected hostname.
Frequently asked questions
Does www or non-www rank better?
No. Google has not said that either form ranks better. A consistent choice with a redirect simply avoids duplicate versions of your pages.
Can I change my mind later?
Yes, but treat it as a small site move. Redirect every old URL to its new equivalent with a 301, update internal links and canonical tags, and watch the Page indexing report in Search Console for a few weeks.
Do I need both versions in DNS?
Usually yes. The version you redirect away from still has to resolve and answer, so that old links and typed addresses reach the redirect instead of an error.
Related guides
- WWW vs non-WWW: choose one canonical host and redirect the other
- Nginx and Apache redirects for SEO
- Canonical URLs and duplicate pages
- Redirect chains and loops
Want to see how your own addresses behave? Try the free website sample.