Redirects · Checked once per domain
WWW to non-WWW (or vice versa) redirectsWhat it checks and how to fix it
What it checks
Requests the same URL on the other host form: www when the site is on the bare domain, or the bare domain when it is on www. Passes when that host redirects to the audited host or does not serve the page, and warns when both versions answer 200, when the redirect points to another host, or when the other form cannot be reached.
Why it matters
When example.com and www.example.com both serve the same pages, search engines see two copies of the site and split links and ranking signals between them, and analytics, cookies and sessions are split too. Picking one canonical host and permanently redirecting the other consolidates them.
How to fix it
Choose one host as canonical and permanently redirect the other to it, keeping the path. The redirecting host needs DNS and a valid certificate too.
# nginx
server {
listen 443 ssl;
server_name www.example.com;
# ssl_certificate must cover www.example.com
return 301 https://example.com$request_uri;
}
# Apache
<VirtualHost *:443>
ServerName www.example.com
# SSLEngine on + certificate covering www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
# Rails: config/routes.rb
constraints(host: "www.example.com") do
get "(*path)", to: redirect(host: "example.com", status: 301), format: false
end
Cloudflare: Rules → Redirect Rules → create from the "Redirect from WWW to root" template (or the reverse), and make sure the www DNS record exists and is proxied.
curl -sI https://www.example.com/