All guides · SEO

www vs non-www: choosing one host

example.com and www.example.com are two different hostnames. Many sites answer on both and serve the same pages on each. Neither choice is better for search; what matters is that you pick one and send the other to it.

Why it matters

When both hosts serve the same content, every page exists twice. Search engines have to decide which copy to index, and links that other sites point at your pages are split between the two. Logins and other cookie-based features can also behave inconsistently, because a cookie set without a Domain attribute is only sent back to the exact host that set it.

A single permanent redirect from one host to the other removes the duplicate and consolidates those signals on one URL.

What we check

We request the same page on the other host: if you scanned https://example.com/pricing, we request https://www.example.com/pricing, and the other way round. We look at the first response only.

Result When
Pass the other host redirects to the scanned host
Pass the other host has no DNS record, so nothing is served there
Needs attention the other host returns 200 with its own copy of the page
Info the other host redirects somewhere else, or returns an error status
Couldn’t test the request failed, for example because of a TLS certificate error

The check does not apply to IP addresses or single-label hostnames. It looks at where the redirect goes, not at its status code, so make sure you use a permanent one yourself.

If the scanned host is the one that redirects (for example you scanned www.example.com and it sends visitors to example.com), the scan follows that redirect first and tests the final host.

How to fix

Decide which host is your main one, then:

  1. Make sure both hosts have DNS records and that your TLS certificate covers both names. Otherwise visitors to the other host see a certificate error before any redirect happens.
  2. Redirect every request on the other host to the same path on the main host with a 301 (or 308) permanent redirect.
  3. Use the main host everywhere else: canonical links, sitemap, internal links, Open Graph URLs.

Nginx (main host is example.com):

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name www.example.com;
    # ssl_certificate lines for a certificate that covers www.example.com
    return 301 https://example.com$request_uri;
}

Apache (in the site config or .htaccess):

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]

Cloudflare: Rules → Redirect Rules. Match requests where the hostname equals www.example.com and redirect dynamically to concat("https://example.com", http.request.uri.path) with status 301, keeping the query string. The www record must be proxied (orange cloud) for the rule to run.

Hosting platforms such as Netlify, Vercel and most managed WordPress hosts have a “primary domain” setting that adds this redirect for you when both domains are attached to the site.

Things to watch

  • Keep the path and query string in the redirect. Sending every page to the home page loses the value of deep links.
  • Keep chains short. Avoid sending visitors through several redirects in a row; see redirect chains. One exception: if you plan to use HSTS preloading, plain HTTP must first redirect to HTTPS on the same host, so http://www.example.com → https://www.example.com → https://example.com is expected there.
  • If you switch your main host on an existing site, update canonicals and sitemaps at the same time and keep the redirects in place permanently.

Google covers redirects and their effect on search in Redirects and Google Search.

Last updated October 24, 2026