Pick one canonical hostname

Serve your site from a single address and redirect all the others to it.

15 min

why this matters

When example.com and www.example.com both serve content, search engines split your ranking signals across two sites and your analytics counts one visitor as two.

Step by step

  1. 1

    Decide which one wins

    Either is fine — pick the version already used in most of your links and advertising, and stick to it everywhere.

  2. 2

    Redirect the other version

    Give the non-canonical hostname its own server block that only redirects.

    server {
      listen 443 ssl;
      server_name www.example.com;
      return 301 https://example.com$request_uri;
    }
  3. 3

    Add a canonical tag on every page

    This is your backstop for parameter and tracking-tagged URLs.

    <link rel="canonical" href="https://example.com/pricing" />
  4. 4

    Update the places that hardcode the old host

    Sitemap, robots.txt, Search Console property, email templates, ad destination URLs and any hardcoded links in your app.

how to check it worked

  • Every variant ends on the same final URL after redirects
  • There is exactly one 301 hop, never a chain
Re-scan my site

related guides