Blog

/

Domains & DNS

www or non-www: how to redirect one to the other

·

7

min

·

Diagram of www.example.com redirecting with a 301 into example.com so both resolve to one canonical domain

Most websites can be reached two ways: with www and without it. To visitors, they look the same.

To search engines, they’re two different addresses. If both load the same page, you end up with duplicate URLs, split links and reports that don’t add up.

The fix is simple: pick one version and redirect the other to it.

Does it matter which one you choose?

Not really. Neither version ranks better. What matters is choosing one and using it everywhere.

A few practical points can tip the decision:

  • Shorter is easier to say and type, which favours the bare domain.

  • Some hosting platforms prefer www, because a www CNAME is easier to route than an apex domain.

  • Keep what you already have. If your site has used www for years, switching now creates work for no gain.

Step 1: make both versions resolve

Both hostnames need DNS records, or the redirect never runs:

  • the bare domain, usually with A records

  • www, usually with a CNAME

If www has no record at all, visitors who type it see an error. Our post on A records and CNAMEs explains which goes where.

Step 2: redirect the other version

Set a permanent 301 redirect from the version you’re not using to the one you are, keeping the path:

www.example.com/pricing → example.com/pricing

Keep the path and query string. Sending every www URL to the homepage throws away the context of the page people wanted.

Where to set it depends on your setup:

  • Website platforms often let you choose a primary domain and redirect the other version for you. Check your platform’s domain settings first.

  • Your server can handle it in Apache or Nginx configuration.

  • A redirect service can handle it at the DNS level, before the request reaches your site.

Step 3: make everything else agree

The redirect is the safety net. The rest of your setup should point to the chosen version directly:

  • canonical tags on every page

  • internal links and navigation

  • your XML sitemap

  • links in emails, ads and social profiles

That way, most visitors never need the redirect at all.

Avoid the two common mistakes

A loop. One system sends example.com to www, another sends it back. This often happens when a host and a CDN each have their own setting. If you see ERR_TOO_MANY_REDIRECTS, check both.

A chain. For example http://www.example.com → https://www.example.com → https://example.com. It works, but each hop adds a little delay. Where you can, redirect straight to the final version.

How Redirect Supply handles www

When you connect a domain to Redirect Supply, both versions are handled automatically. www always redirects to the bare domain first, so one canonical version is used. Then your rules run. That’s two hops for www visitors by design. Our www troubleshooting doc explains it.

If your website itself should live on www, see our apex to www use case.

What about Search Console?

Google treats www and non-www as different addresses. If you use a domain property in Search Console, it covers both automatically. If you use URL-prefix properties, add the version you chose and keep an eye on both.

You don’t need the Change of Address tool for this. Google’s documentation says www to non-www changes on the same domain should use redirects and canonical tags instead.

Check the result

Test all four combinations with our redirect tester:

  • http://example.com

  • http://www.example.com

  • https://example.com

  • https://www.example.com

All four should end on the same URL, with permanent redirects and no loops.

Ready to keep every link alive?

Ready to keep every link alive?

Ready to keep every link alive?