TTKTheTextKit
Technical SEO7 min read

www vs Non-www: How to Pick One and Redirect the Other

www vs non-www explained: why you pick one, which four addresses to cover, and the 307 redirect we found on our own site and changed to a permanent 308.

By TheTextKit TeamPublished

Our www redirect before and after: a 307 temporary redirect changed to a 308 permanent one, four address variants covered

A table of three results about the www redirect of our own site. Before, www sent visitors on with a 307 temporary redirect. After, it uses a 308 permanent redirect. Four address variants are covered.

The www vs non-www question has a short answer: it doesn't matter which you pick, but you must pick one. Choose www.example.com or example.com as your main address, send every other version to it with a permanent redirect, and use that same address in your canonical tags and sitemap. We checked our own site and found the redirect was a temporary 307, which isn't the signal you want, so we changed it to a permanent 308. This guide shows what to cover, how to test it and what Google says.

www vs non-www: which one should you choose?

Google doesn't pick a side. Its guide to consolidating duplicate URLs lists https://example.com/home, https://home.example.com and https://www.example.com as ways to reach one page. It tells you to choose one as the canonical address and to use redirects to send traffic from the others.

Your host may have an opinion. Vercel's documentation recommends www as the primary domain, with a redirect from the bare domain, because it gives Vercel's network more control over incoming traffic and the redirect is cached in visitors' browsers. It says that redirecting www to the bare domain also works, but gives Vercel less control. It also explains that the DNS rules don't allow a CNAME record on a bare domain, which is the technical reason behind its advice.

ChoiceWhat the sources say
Either oneGoogle: pick one as the canonical address and redirect the rest
www as the main addressVercel's recommendation, for control over traffic
Bare domain as the main addressWorks, with less control for the host

We use the bare domain, thetextkit.com. Both are fine for search. What isn't fine is leaving both reachable at 200, so that the same page exists at two addresses.

The four addresses to cover

Every site has four front doors, because each of http and https can be used with or without www. If your main address is https://example.com, the other three should redirect to it, and only the main one should load the page.

AddressWhat it should do
http://example.comRedirect to the main address
http://www.example.comRedirect to the main address
https://www.example.comRedirect to the main address
https://example.comLoad the page (200)
The four addresses of a website: three redirect to the main address and https without www loads the page

A table of the four versions of a website address. http without www, http with www and https with www should all redirect to the main address. https without www is the main address and loads the page.

Three redirect, one loads.

On the https side, Google says it prefers HTTPS pages over equivalent HTTP pages as the canonical, unless there are problems such as an invalid certificate. A redirect from http to https backs that up. Two hops, such as http://www to https://www and then to the bare domain, still end on the right page. One hop is cleaner, because Google's site move guide notes that chained redirects add latency.

What we found on our own site

We run this site on Vercel, with the bare domain as the main address. When we audited it, the www version of every URL returned a 307, a temporary redirect, to the bare domain. Vercel's documentation says it attempts this redirect automatically, and ours had not been set up by hand. Google's guide to redirects explains why the code matters. A permanent redirect (301 or 308) signals that the target should be canonical. A temporary one (302, 303 or 307) keeps the source page as the one shown in results, though the target may still be indexed if other signals point to it.

We have no evidence that the 307 caused any problem. But it said "might change back" for something we meant to be permanent. So we added www.thetextkit.com to the project in the Vercel dashboard, with a redirect to the bare domain and the status code 308. Then we requested the same addresses again.

AddressBeforeAfter
https://www...307308
http://... (bare domain)308308
https://... (bare domain)200200
Our redirects before and after: https www changed from 307 to 308, http bare stayed 308, https bare stayed 200

A table of our site's redirects before and after the change. https with www changed from a 307 to a 308. http without www stayed at 308. https without www stayed at 200.

Only the www redirect needed to change.

After the change, every checked www page, including the home page, a tool, an article and the sitemap, returned a 308 to the same path on the bare domain. An http://www address took two permanent hops, first to https://www and then to the bare domain, and ended on the right page with a 200.

How to test your redirect

To test a www vs non-www redirect, you need the status code and the Location header for each of the four addresses, without following the redirect. With curl it is one command per address:

curl -I https://www.example.com/

Or run this in Node 18 or later to check all four at once:

for (const url of ['http://example.com/', 'http://www.example.com/', 'https://www.example.com/', 'https://example.com/']) {
  const r = await fetch(url, { redirect: 'manual' })
  console.log(url, r.status, r.headers.get('location'))
}

Read the result like this. Three of the four should show a 301 or 308 and a Location that points at your main address. One should show 200. Check a deeper page as well, such as /blog/some-post, because some setups redirect only the home page and leave the rest at 200 on both versions. A trailing slash is a separate matter: our site sends /tools/word-counter/ to /tools/word-counter with a 308.

Make every signal agree

The redirect is only one part of the www vs non-www setup, and it is one of three signals. Google's guide lists them in order of influence. Redirects are a strong signal that the target should be canonical, and a rel="canonical" link is also a strong signal. Including a URL in a sitemap is a weak one. They work best when they all name the same address.

SignalStrength, according to Google
RedirectStrong
rel="canonical" linkStrong
SitemapWeak
How strong each canonical signal is, according to Google: redirect strong, rel canonical strong, sitemap weak

A table of three signals that help Google pick the canonical address. A redirect is a strong signal. A rel canonical link is a strong signal. Including a URL in a sitemap is a weak signal.

Use all three, pointing at the same address.

We checked ours the same way. All 119 URLs in our sitemap use the bare domain, and every one of the 119 pages returns a 200 with a canonical tag that points to its own address on the bare domain. You can set the canonical in the Meta Tag Generator and build the sitemap with the XML Sitemap Generator, and our guide to the XML sitemap explains what to put in it.

Check on our siteResult
Sitemap URLs on the main domain119 of 119
Pages that return 200119 of 119
Canonical tags pointing at their own page119 of 119
Our site checked for one canonical address: 119 of 119 sitemap URLs, pages returning 200 and canonical tags agree

A table of three checks on our site. All 119 sitemap URLs use the main domain. All 119 pages return 200. All 119 canonical tags point at their own page on the main domain.

All three signals agree on one address.

When you do not need a Change of Address

If you move to a different domain, Search Console has a Change of Address tool. Google's site move guide says you don't need it for HTTP to HTTPS moves or for changes between www and non-www. A single rule from the other versions is enough. For moving many pages, see our guide to bulk 301 redirects.

Limits

Our test of a www vs non-www redirect covered one site on one host, and Vercel was the only host we changed. Hosts differ in whether they redirect for you, which status code they use and where the setting lives, so read your own host's documentation before you assume the same.

On Apache or NGINX the rule is a few lines in the server configuration, and our Redirect Generator writes path rules, not whole-host rules, so use your host's own setting for the www redirect. We can't see inside Google's index, so we don't claim the 307 held anything back. We only know that a permanent redirect says what we mean.

Frequently asked questions

Is www or non-www better for SEO?

Google does not say one is better. Its guide lists them as different ways to reach the same page and tells you to pick one as the canonical address and redirect the others to it. Consistency matters more than the choice.

Should a www redirect be a 301 or a 307?

A permanent one, 301 or 308, when you have decided on the final address. Google treats 301 and 308 as permanent, which signals that the target should be canonical, while a temporary redirect keeps the old address as the one shown.

Do I need a Change of Address request for www?

No. Google's site move guide says you don't need a Change of Address request in Search Console for an HTTP to HTTPS move or a change between www and non-www.

How do I test a www redirect?

Request the four versions of your address, http and https with and without www, without following redirects, and check the status code and the Location header of each. Only one should return 200.

Does Vercel redirect www automatically?

Vercel's documentation says that if a visitor uses your domain with or without www it will attempt to redirect automatically. You may still want to add the redirect yourself so you control its status code.

Check your redirects now

Use the Redirect Generator for page-level rules, and check the whole-host redirect with the four requests above. Everything in our tools runs in your browser, so nothing you type is uploaded.

Try these free tools

100% in your browser

Keep reading

All articles →