Trailing slashes: the small URL detail that creates redirects
linkbruno.comIs it /pricing or /pricing/? To a person, they're the same page. To a web server, they're two different URLs, and how your site handles the difference affects redirects, duplicate pages and broken links.
What actually happens
Most sites pick one form and redirect the other to it. Request /pricing on a site that prefers slashes, and the server answers with a 301 to /pricing/. That's fine for one click, but it adds up:
- Every internal link written in the "wrong" form costs visitors an extra round trip.
- Search engines have to follow the redirect before they reach the content.
- Combined with other redirects (http to https, non-www to www), one click can bounce through three hops.
You can see it with curl:
curl -sI https://example.com/pricing | grep -iE '^(HTTP|location)'
Where it turns into broken links
Things get worse when a site handles the two forms inconsistently:
- Relative links change meaning. On
/docs/a link toguidegoes to/docs/guide. On/docs(no slash) the same link goes to/guide, which may not exist. - Static hosts disagree. One host serves
/aboutfromabout.html; another expects/about/index.html. After a migration, half your links can start returning 404. - No redirect at all. Some setups serve the page for one form and a 404 for the other. Links copied by hand from the browser bar fail at random.
- Both forms return 200. No 404s, but now there are two copies of every page. A canonical tag helps, but it's better to pick one.
How to fix it
- Pick one form for the whole site. Either works; consistency is what matters.
- Redirect the other form with a single 301, directly to the final URL, including https and your preferred host in one step.
- Update internal links so they already use the preferred form. Menus, footers and templates first, because they appear on every page.
- List the preferred form in your sitemap and canonical tags.
- Use root-relative links (
/docs/guide) instead of bare relative ones (guide) so their meaning doesn't depend on the current URL.
Check after every migration
Changing hosts, frameworks or static site generators is when trailing-slash behaviour most often changes without anyone deciding it should. After a move, test a handful of URLs in both forms and check internal links across the site.
A crawler that follows redirects hop by hop makes this visible. linkbruno.com checks every link on your pages on a schedule and shows redirect chains, so a sudden wave of slash redirects or 404s shows up right away.
Related reading
- How to check mailto: and tel: links before they cost you leads
- Changed a URL slug? A cleanup plan for every link that pointed to it
- How to find mixed content (http:// links) on an HTTPS site
- Why links in old email newsletters break, and how to prevent it
- Too many broken links? How to decide which to fix first
- How to find broken links inside PDFs and downloadable files
- Check links in Markdown docs with a 60-line Python script