Trailing slashes and www: choosing one URL version
Google treats www and non-www, and slash and no slash, as different URLs. Here is how to pick one version and make every signal agree.
Your homepage can load at four addresses: with or without www, over http or https. Every inner page can also load with or without a trailing slash. If all of those return the same page, you have a duplicate URL problem you never created on purpose. This guide covers how to pick one version and make every signal point to it.
Why small URL differences matter
To a crawler, a URL is a string. Two strings are two URLs, even when a human would call them the same page. The host name is not case sensitive, but the path is. And www.example.com is a different host from example.com.
Google usually works out which version you prefer and folds the duplicates together. That is a guess, though, and guesses can go wrong. Links, analytics rows, and Search Console data can split across versions. AI crawlers have no obligation to be as forgiving.
The variants to check
- Protocol: http versus https.
- Host: www versus the bare domain.
- Trailing slash: /guide versus /guide/.
- Case and index files: /Guide versus /guide, and /index.html versus /.
One exception helps here. For the root of a site, the slash makes no difference. Google treats example.com and example.com/ as the same address. For every other path, the slash does count, so /guide and /guide/ are separate URLs.
Picking the preferred version
Google has said it does not care which you choose. Either www or the bare domain is fine, and slash or no slash is fine. What matters is that you pick one and stick to it. A few practical rules make the choice easy.
- Always use https.
- Keep whatever version already has the most links and indexed pages. Switching has a cost, so only do it for a real reason.
- On a new site, choose the bare domain or www based on your DNS and hosting setup. Some DNS providers make a bare domain harder to point at a CDN.
- Match the slash style your framework or CMS produces by default. Fighting it creates redirect rules you will have to maintain.
Make every signal agree
A redirect is the strongest signal, so start there. Send every non-preferred variant to the preferred one with a single 301. Do it in one hop, not a chain. A request for http://example.com/guide should land on https://www.example.com/guide/ directly, if that is your chosen form.
Then line up the softer signals. They should all name the same URL.
- Set a self-referencing canonical tag on each page using the full preferred URL.
- List only preferred URLs in your XML sitemap.
- Write internal links to the preferred form, so users and crawlers never hit a redirect.
- Use the preferred form in hreflang annotations and structured data URLs.
- Add the same form to any feeds and social profiles you control.
Internal links are the step people skip. A redirect fixes the outcome, but a site full of links to the wrong version still sends every crawler through an extra request.
How to test your setup
You do not need a paid tool. Request each variant and read the response. A command line tool like curl with the head-only flag shows the status code and the Location header for each one.
- Every non-preferred variant should return a 301 with a Location header pointing at the final URL.
- The preferred URL should return 200 and nothing else.
- Test a deep page, not only the homepage. Redirect rules often cover the root and miss the rest.
- Test with and without a query string. Some rules drop parameters you meant to keep.
In Search Console, a Domain property combines all host and protocol variants into one report. A URL-prefix property only shows the exact version you enter. If your numbers look low, check which kind of property you are reading.
Common mistakes
Redirect loops from conflicting rules
A server rule adds the slash while the CMS strips it. The page bounces between two URLs until the browser gives up. Check where the rules live, since a CDN, a web server, and the application can all rewrite URLs.
Canonical tags that fight the redirect
If a page redirects to the slash version but its canonical tag names the no-slash version, you have sent two opposite instructions. Google may choose either one.
Redirecting everything to the homepage
A catch-all rule that sends unknown variants to the root loses the page-level match. Map each variant to its own preferred page.
What to do this week
Write down your preferred form in one line, such as https, www, trailing slash. Then run a deep page through all the variants and confirm each returns a single 301 to that form. Finally, crawl your own site and fix internal links that still point at the old version. This is an hour of work, and it removes a whole class of duplicate problems.