Skip to content

Trailing slash in URLs: are /page and /page/ different pages?

Trailing slash SEO explained: Google treats /page and /page/ as two URLs except at the root. How to pick one form, redirect in one hop and avoid slash loops.

By Crawlito · 8 min read

In short

  • Google treats /fish and /fish/ as separate URLs, but https://example.com and https://example.com/ are the same URL, because RFC 3986 and RFC 9110 treat an empty http or https path as /.
  • Google says both forms returning 200 with the same content is legitimate, and recommends picking one, linking to it, listing it in the sitemap and 301-redirecting the other.
  • Next.js by default, and Vercel when trailingSlash is set, answer the non-preferred form with a 308 redirect, which Google treats as permanent; Cloudflare Workers static assets use 307, which Google treats as temporary.
  • Netlify matches redirect rules with and without a trailing slash and its docs warn that a rule removing a slash can cause an infinite redirect.
  • Slash loops usually come from two layers that disagree, such as a CDN that adds the slash and a framework that removes it.
On this page

Yes. To Google, /page and /page/ are two different URLs that happen to differ by one character, and it crawls and evaluates each on its own. The one exception is the root of a host: https://example.com and https://example.com/ are the same URL. Either form is fine. What matters is that you choose one, redirect the other to it in a single permanent hop, and use the chosen form everywhere you write a URL.

The canonical tags guide lists the trailing slash as one source of duplicates among many, and URL structure best practices covers slugs, case and folders. This post covers the slash on its own: what the standards say, what each common framework and host does by default, and how to stop two layers from fighting over it.

Does Google treat /page and /page/ as different URLs?

Google answered this directly in its post To slash or not to slash. The key points, still consistent with its current guidance:

URLsHow Google treats them
https://example.com/fish and https://example.com/fish/Two separate URLs, treated "separately (and equally)"
https://example.com and https://example.com/Equivalent, so the root cannot be redirected from one to the other
Both forms return 200 with the same contentCommon and acceptable; Google calls leaving it "perfectly legitimate"
Both forms return 200 with different contentAllowed, but confusing for people

The post notes that a trailing slash commonly indicates a directory, but that is only a convention. Google does not prefer either form.

If both forms work and you do nothing, Google's guide to consolidating duplicate URLs says it picks the version it considers best to show. Fixing it still helps: the same guide lists avoiding crawl time spent on duplicates as a reason to consolidate, and stating a preference removes the chance that Google picks the form you did not want. AI search crawlers are a separate case. Their operators do not document how they merge URL variants, so the safe assumption is that each form a crawler finds is a separate fetch.

Why the root is the exception: RFC 3986

The generic URI standard, RFC 3986 section 6.2, explains the difference.

  • Scheme-based normalization (6.2.3). A URI with an authority and an empty path "should be normalized to a path of "/"", and the http scheme defines an empty path as equivalent to /. RFC 9110 section 4.2.3 says the same for both http and https. So https://example.com and https://example.com/ are the same URI, and RFC 9112 requires an HTTP/1.1 client to send / as the path when the URL's path is empty.
  • Protocol-based normalization (6.2.4). No such rule covers other paths, so http://example.com/data and http://example.com/data/ are two URIs. The RFC says a web spider that sees one redirect to the other will likely regard the two as equivalent in future, and stresses that this is "only appropriate when equivalence is clearly indicated" by the server's responses.

That second point is the practical one. The slash only becomes irrelevant when your server says so, and the way it says so is a redirect.

Relative links also resolve differently. Under RFC 3986's merge rule (section 5.2.3), a relative path replaces everything after the last / of the current page's path. So a link to g on /b/c/ resolves to /b/c/g, while the same link on /b/c resolves to /b/g. If a page works at both forms, its relative image, CSS and link paths can break on one of them.

How to pick one form and enforce it

Either form works. A few things decide it in practice:

  1. Keep what you already have. If your indexed URLs, backlinks and sitemap use one form, keep it. Switching means redirecting every URL on the site.
  2. Follow your framework's default if you are starting fresh. Fighting it means more configuration that can drift.
  3. Leave files alone. URLs with a file extension (/robots.txt, /sitemap.xml, /logo.png) should never get a slash added. Next.js and Vercel both exempt them.

Then apply Google's steps from the same post:

  • Redirect the other form with a permanent redirect. Google's redirects documentation treats 301 and 308 as permanent, which signal that the target should be canonical, and 302, 303 and 307 as temporary, which do not.
  • Use the chosen form in internal links and the sitemap. The slash post says to list only the preferred version in your sitemap. Google's consolidation guide asks you to link to the canonical URL rather than a duplicate, and ranks redirects and rel="canonical" as strong signals and sitemaps as a weak one.
  • Use rel="canonical" if you cannot redirect. Google's slash post calls it a strong option. The tag must name the exact chosen form, slash included.

What frameworks and hosts do by default

This is where most slash problems start: the setting lives in a different place on every stack, and the redirect status code differs too.

StackDefaultSettingRedirect used
Next.jsRemoves the slash: /about/ redirects to /abouttrailingSlash: true in next.config.js reverses it308
Vercel (vercel.json)No redirect: both forms serve the same content"trailingSlash": true or false308
Cloudflare Workers static assetsauto-trailing-slash: files without a slash, folder indexes with onehtml_handling under assets in the Wrangler config307
NetlifyPretty URLs on: /about forwarded to /about/Project configuration > Developer settings > Post processing > Pretty URLsNot stated in the redirect docs

Details worth knowing from each operator's documentation:

  • Next.js. The trailingSlash page says that with trailingSlash: true, static file URLs and paths under .well-known/ keep no slash, and with output: "export" the /about page is written as /about/index.html. The skipTrailingSlashRedirect page documents the 308 responses and adds that if the last path segment contains a dot, Next.js treats it as a file and removes the slash whatever the setting, so /version/1.2.3/ redirects to /version/1.2.3.
  • Vercel. The vercel.json reference says leaving trailingSlash undefined serves both forms without redirecting, and notes that this "is not recommended" because search engines may index duplicates.
  • Cloudflare Workers. The HTML handling page offers auto-trailing-slash (the default), force-trailing-slash, drop-trailing-slash and none. All the redirects in its tables are 307, which Google classes as temporary. If you rely on them, make sure your canonical tags, sitemap and links agree with the redirect target.
  • Netlify. The redirect options page says you cannot add or remove a trailing slash with a redirect rule, and that rules match paths with or without a slash.

A minimal Next.js setup for the slash form, with a canonical that matches:

js
// next.config.js
module.exports = {
  trailingSlash: true,
}
html
<link rel="canonical" href="https://www.example.com/pricing/">

On your own server, the same rule in nginx, removing the slash from everything except the root:

nginx
# 301 /pricing/ -> /pricing, leave / alone
rewrite ^/(.+)/$ /$1 permanent;

How to avoid trailing slash redirect loops

A loop happens when two layers disagree. Layer A turns /pricing into /pricing/, layer B turns /pricing/ back into /pricing, and the client bounces until it gives up. Crawlers report this as a redirect error; see redirect errors in Search Console for the report.

Pairings that can loop when both are active:

Layer that adds the slashLayer that removes it
Netlify Pretty URLsA framework or function that removes slashes
Cloudflare force-trailing-slashA Redirect Rule or Worker that strips slashes
trailingSlash: true in Next.js"trailingSlash": false in vercel.json, or an nginx rewrite
Apache's DirectorySlash, on by default, adding a slash to real directoriesA CMS or proxy rule removing it

Netlify's docs give the simplest example of all: the rule /blog/remove-my-slashes/ /blog/remove-my-slashes 301! causes an infinite redirect, because Netlify treats both paths as the same.

The fix is always the same: decide which single layer owns the slash and turn the behaviour off everywhere else. In Next.js, skipTrailingSlashRedirect: true hands the job to your own Proxy code; on Vercel, leave trailingSlash unset in vercel.json if Next.js already handles it.

A second, quieter problem is chains. If http://example.com/pricing goes to https://example.com/pricing, then to https://www.example.com/pricing, then to https://www.example.com/pricing/, every crawler pays three hops. Merge protocol, host and slash into one redirect at the edge. The www vs non-www guide covers the host part, and redirect status codes covers which code to use.

How to check your trailing slash handling

Run each form through curl and read the status and the target:

bash
for u in "https://www.example.com/pricing" "https://www.example.com/pricing/" \
         "http://example.com/pricing/" "https://www.example.com/robots.txt/"; do
  printf '%s -> ' "$u"
  curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' "$u"
done

What a clean result looks like, for a site that removes slashes:

https://www.example.com/pricing -> 200
https://www.example.com/pricing/ -> 308 https://www.example.com/pricing
http://example.com/pricing/ -> 301 https://www.example.com/pricing
https://www.example.com/robots.txt/ -> 308 https://www.example.com/robots.txt

Then check the rest:

  1. One hop only. Use curl -sIL on the non-preferred form and count the location headers. More than one means a chain.
  2. Permanent code. The redirect should be 301 or 308. A 302 or 307 is temporary in Google's documentation.
  3. Canonical matches. The canonical tag on the 200 response names the exact same string, slash included.
  4. Sitemap and links match. Search your sitemap and rendered navigation for the other form. Every hit is a link that costs a redirect.
  5. Search Console agrees. URL Inspection shows the Google-selected canonical; it should be the form you chose.

Frequently asked questions

Is a trailing slash better for SEO?

No. Google treats both forms equally and does not prefer either. Consistency matters, not the choice.

Do I need to redirect https://example.com to https://example.com/?

No. They are the same URL: under the http and https schemes an empty path equals /, so clients request / for both. Google notes the root cannot be redirected.

Is a canonical tag enough without a redirect?

It works, and Google calls it a strong option when you cannot redirect. A redirect is better, because crawlers no longer receive a second full copy of the page and visitors land on the URL you chose.

Why does my site loop between /page and /page/?

Two layers disagree about the slash, for example a host that adds it and a framework that removes it. Pick one layer to own the redirect and turn the behaviour off in the other.

Should robots.txt and sitemap.xml have a trailing slash?

No. Files with an extension should be served without one. Next.js and Vercel exempt file URLs from adding a slash, and robots.txt must be at /robots.txt exactly.

Check how crawlers see your URLs

A slash rule is easy to set and easy to break when someone adds a CDN rule or changes a framework setting. After any change, run the curl loop above, then the free check on a key page to confirm the main AI crawlers can still fetch it. If you want the whole site reviewed, up to 500 pages, an audit delivers a PDF with evidence and prioritized fixes.

Filed under Access and robots.txt. Topics: redirects, canonical, nextjs, technical-seo