WWW vs Non-WWW: Which Should You Choose?
Neither www nor non-www ranks better; Google treats them as two separate hosts. Choose one, serve the site only there, and 301-redirect the other host to it with the path kept. Use the bare domain on simple shared hosting; use www when a CDN needs a CNAME or cookies must stay off subdomains.
For site owners and developers setting up a new domain, or fixing a site that answers on both hostnames at once.
knowledge
- Read time
- 4 min
- Sections
- 7
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 14 November 2026.
Does www vs non-www affect SEO?
No: Google gives no ranking benefit to www or to the bare domain, but it does treat www.example.com and example.com as two separate hosts if both return pages. Two live hosts split backlinks, crawl activity and Search Console data between duplicate copies of every URL.
So the SEO decision is not which name to use; it is to use exactly one. Serve the site on the chosen host, send a single 301 redirect from the other, and use the chosen host everywhere you control: internal links, canonical tags, the XML sitemap, hreflang and social profiles.
| Setup | Result |
|---|---|
| Both hosts serve the site | Duplicate pages; Google picks a canonical itself and signals split |
| One host serves, the other 302-redirects | Treated as temporary; consolidation is slower and less certain |
| One host serves, the other 301-redirects with the path kept | All links and reports land on one URL per page |
What is the www in a web address?
www is simply a subdomain, a hostname under your domain, exactly like mail.example.com or shop.example.com. The bare name, example.com, is called the apex, root or naked domain. Early web servers were given the www label by convention, and it stuck.
Because www is just a label, it needs its own DNS record. If you create the apex A record but forget the www record (or the reverse), half your visitors see a “site can't be reached” error. Most browsers now hide www in the address bar, so visitors rarely know which host they opened; servers, crawlers and cookies always do.
When is www the easier DNS choice?
www is easier when a CDN, load balancer or hosted platform gives you a hostname to point at, because www can be a CNAME and the apex usually cannot. DNS rules forbid a CNAME at the apex, since the apex must also hold SOA and NS records.
- Apex on shared hosting: one A record to the server IP is all you need, so the bare domain is the simpler choice.
- www behind a CDN or platform: a CNAME at www follows the provider when its IP addresses change.
- Apex behind a CDN: works only if your DNS host supports ALIAS, ANAME or CNAME flattening.
The record types are compared in A record vs CNAME, and every record you may need is listed in DNS records explained.
How do cookies behave on www and non-www?
A cookie set with Domain=example.com is sent to the apex and to every subdomain; a host-only cookie set on www.example.com stays on www. That rule decides whether login sessions survive a host switch and how far your cookies travel.
A site on the bare domain that sets domain-wide cookies also sends them to mail.example.com, cdn.example.com and any other subdomain, adding bytes to every request and exposing session cookies to whatever runs there. A site on www can keep cookies on the website host only, which is one reason large sites and CDN users prefer www. If you move an existing site from www to the apex, expect every visitor to be logged out once, because the old host-only cookie does not follow them.
Which should you choose, www or non-www?
For a new small business site on shared hosting, choose the bare domain; choose www if a CDN or platform sits in front, or if you run several subdomains and want cookies isolated. If a site already ranks on one host, keep that host; switching gains nothing and costs a reindexing cycle.
| Situation | Pick | Reason |
|---|---|---|
| New site, shared hosting, one A record | example.com | Shorter, matches how people say it |
| Site behind a CDN or hosted platform | www.example.com | CNAME allowed at www |
| Many subdomains with logins (app., mail., shop.) | www.example.com | Cookies can stay on the website host |
| Existing site with rankings | The host already indexed | Avoids a needless migration |
How to redirect www to non-www (or the reverse)
Add one permanent 301 redirect from the unused host to the chosen host that keeps the path and query string, and make sure your SSL certificate covers both names. The redirect must be a single hop: https://www.example.com/page should go straight to https://example.com/page, not via http.
On Apache or LiteSpeed, put this at the top of the site's .htaccess file to send www to the bare domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301]
To force www instead, swap the condition and target:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]
mod_rewrite carries the original query string across automatically. On Nginx, give the unused host its own server block:
server {
listen 443 ssl;
server_name www.example.com;
# ssl_certificate and ssl_certificate_key for www.example.com
return 301 https://example.com$request_uri;
}
In WordPress, set both Settings → General URL fields to the chosen host first; if one field says www and the other does not, the server rule causes a redirect loop. Then test with curl -I https://www.example.com/test?x=1, which should return 301 with Location: https://example.com/test?x=1. More patterns are in the .htaccess 301 redirect guide, and the protocol half of the job is in redirecting HTTP to HTTPS.
How do you tell Google Search Console which host you chose?
Search Console no longer has a preferred-domain setting; Google reads your choice from the 301 redirect, canonical tags and the sitemap. Add a Domain property, which covers both hosts and all subdomains, and submit a sitemap that lists only canonical-host URLs.
After the redirect has been live for a few weeks, the Page indexing report should list the unused host's URLs as “Page with redirect” instead of indexed pages. If they still show as indexed, check for internal links or a sitemap still pointing at the old host. The Search Console guide walks through the reports, and an SEO audit checks host consistency before any link building starts.
Frequently asked questions
Why do www and non-www open different websites?
Because they are different hostnames, and each can point to a different IP address or document root. This usually happens when an old hosting account still holds one name. Point both DNS records at the same server, serve one, and 301 the other.
Does one SSL certificate cover both www and non-www?
Most standard certificates, including free Let's Encrypt certificates issued by hosting panels, list both example.com and www.example.com. Without coverage for the unused host, visitors see a certificate warning before the redirect can run.
Will switching from www to non-www lose rankings?
A clean page-to-page 301 passes signals to the new host, but Google has to recrawl and reprocess every URL, so expect a period of fluctuation. Switch only for a technical reason such as a CDN requirement, never for SEO alone.
Do I need to update backlinks after choosing a host?
No. External links to the old host keep working through the 301. Update only what you control: your internal links, Google Business Profile, social profiles and email signatures, so new links point straight at the canonical host.
Last editorial update: 14 November 2026.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.