www vs non-www: Which Is Better for SEO?
5 min read
## The Oldest Technical SEO Question
"Should I use www.example.com or just example.com?" is one of the first technical SEO questions any site owner encounters, and it continues to generate confusion because the answer has subtle implications for canonicalization, cookie handling, and DNS flexibility.
The direct answer: **it does not significantly matter which you choose, as long as you are consistent**. The indirect answer: there are specific technical scenarios where each option has advantages. The choice interacts with how your SSL certificate is scoped, how 301 redirects are routed, and whether your hosting can use CNAME records at the zone apex. For subdomain-heavy architectures, the www preference also affects cookie scope across all subdomains.
## Why This Question Exists
When the web was first established, www. was a conventional prefix indicating that a hostname was part of the World Wide Web specifically — distinguishing web servers from ftp. (file transfer), mail. (email), or other services on the same domain. Today, that distinction is obsolete. Most sites serve only web content, and the www. prefix has become a stylistic choice rather than a technical requirement.
However, because www. and non-www are technically distinct hostnames, search engines, browsers, and servers treat them as potentially separate sites unless you explicitly configure them to be unified.
## The Canonicalization Requirement
The most important principle: you must canonicalize to one version. Serving identical content on both www.example.com and example.com without a redirect creates duplicate content, which dilutes domain authority and can cause indexing confusion.
The correct configuration:
1. Choose one version as canonical (e.g., www.example.com)
2. Implement a 301 redirect from the other version to the canonical one
3. Set the canonical URL tag on all pages to the canonical version
4. Configure Google Search Console to use the canonical version
Google's John Mueller has confirmed that either version can be the canonical, and both perform equivalently from a ranking perspective once properly configured.
## Technical Arguments for www.
### DNS Flexibility: CNAME Records
www.example.com can point to a CNAME record, which allows your domain to point to another hostname (like a CDN, load balancer, or cloud service) rather than a fixed IP address. This is valuable because:
- CDNs like Cloudflare and Fastly are specified by hostname (e.g., example.cdn.cloudflare.net), not IP address
- Load balancers in cloud environments use dynamic hostnames
- CNAME records automatically update when the target's IP changes
The bare domain (example.com, called the "zone apex" or "naked domain") cannot point to a CNAME record in standard DNS — it must use an A record pointing to a fixed IP address. Some DNS providers (Cloudflare, Route 53, DNSimple) offer "CNAME flattening" or "ALIAS records" that work around this limitation, but standard DNS does not support it.
If your hosting uses dynamic IP addresses or a CDN without CNAME flattening support, www. is technically necessary.
### Cookie Handling
Cookies set on example.com are automatically sent to all subdomains including www.example.com. Cookies set on www.example.com are not automatically sent to other subdomains. For sites with complex subdomain structures (app.example.com, api.example.com), using www. as the primary domain gives you finer cookie scope control.
## Technical Arguments for Non-www (Bare Domain)
### Simpler User Experience
example.com is shorter and easier to type, dictate, and remember than www.example.com. In a mobile-first world where users are more likely to voice-type or manually enter URLs on small keyboards, the shorter form has practical usability advantages that can marginally affect direct traffic.
The memorability advantage of bare domains is real, if small. Users are increasingly accustomed to both formats, but example.com is universally understood while www.example.com can occasionally cause confusion for very non-technical users who may think the "www" is a separate part of the address.
### Common Practice Among Modern Sites
Many high-profile modern sites use bare domains as primary: stripe.com, vercel.com, notion.so, linear.app. This choice is deliberate — these brands optimize for clean, typeable URLs. The absence of www. has become associated with modern, tech-forward identity.
## What Google Says
Google has no preference between www and non-www. The Google Search Central documentation explicitly states: "Either is fine; they're treated the same by Google." The key requirement is consistent canonicalization, not the format itself.
In Google Search Console, you can set the "Preferred Domain" in the old version of Search Console (this setting was deprecated in 2019 as part of the move to the new Search Console). The new Search Console uses domain properties that encompass both www and non-www automatically.
## Implementing the Configuration
### If You Choose www. as Canonical
```nginx
# Nginx: Redirect non-www to www
server {
listen 80;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
```
```apache
# Apache: Redirect non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
```
### If You Choose Non-www as Canonical
```nginx
# Nginx: Redirect www to non-www
server {
listen 80;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
```
## The HTTPS Layer
The www vs. non-www decision interacts with your SSL certificate configuration. A wildcard certificate (*.example.com) covers all subdomains including www.example.com but does NOT cover the bare domain example.com. For a bare domain canonical, you need a certificate that explicitly includes example.com (most modern certificates from Let's Encrypt include both).
## Using TLD Knowledge Quiz to Check Your Canonical Knowledge
Want to test your understanding of canonicalization and URL structure decisions? Our TLD Knowledge Quiz includes questions on www vs. non-www configuration and other technical SEO fundamentals.
## Checklist for www vs. Non-www Configuration
- [ ] Chosen one version as canonical
- [ ] Server-level 301 redirect from non-canonical to canonical version
- [ ] Canonical tags on all pages pointing to canonical version
- [ ] XML sitemap uses canonical version URLs exclusively
- [ ] Google Search Console configured for canonical domain property
- [ ] SSL certificate covers the canonical hostname
- [ ] All internal links use canonical URL format
## Related Guides
- 301 Redirects and Domain Migrations: SEO Guide — How redirects work for canonical enforcement
- HTTPS and SSL: The SEO Connection — SSL certificate configuration for your canonical domain
- Subdomain vs Subdirectory: SEO Implications — Related structural decisions with similar canonicalization implications