www vs. non-www is the choice between www.example.com and example.com as the main address of a website. Both are valid host names, and technically they are different addresses.
Which version is better for SEO?
Google’s documentation on duplicate URLs does not prefer either one. It advises choosing one URL as the canonical and using redirects to send traffic from the other versions to it. If both versions return the same content with status 200, they count as duplicates.
MDN calls the choice a matter of preference. According to reports from hosting and SEO sites, arguments for www include easier DNS setups with CNAME records at some providers and tighter cookie scoping, and arguments for non-www include shorter addresses. Google’s documentation mentions none of these. The Search Console preferred domain setting no longer exists, according to the Google blog post “Bye Bye Preferred Domain setting” (June 2019).
Google also prefers HTTPS pages as canonical and suggests redirects, canonical links or HSTS to support this.
Example
http://example.com 301 -> https://www.example.com/
http://www.example.com 301 -> https://www.example.com/
https://example.com 301 -> https://www.example.com/
Common mistakes
Only the HTTPS version is redirected, and the www variant is forgotten. Redirect every variant in one step to avoid chains.
Sources
- Consolidate duplicate URLs – Google Search Centraldevelopers.google.com
- RFC 3986: URI Generic Syntaxrfc-editor.org
- Choosing between www and non-www URLs – MDN Web Docsdeveloper.mozilla.org
- Bye Bye Preferred Domain setting – Google Search Central Blog, June 2019developers.google.com
Last updated: