Trailing Slash

Does a trailing slash matter for SEO? The root-domain exception, the file-vs-directory history, the REST API gotcha, and copy-pasteable Apache, Nginx, and IIS rules to enforce one format — plus when not to bother changing it.

First published: Jul 3, 2026 · Last updated: Jul 18, 2026 · Advanced
demand #1 in URL Structure#11 in Website Structure#114 in Technical SEO#151 on the site
1 evidence signal on this page

A trailing slash is the / at the end of a URL. example.com and example.com/ are identical — that root-domain case is the one universal rule. Everywhere else, example.com/page and example.com/page/ are different URLs, so if both are live and neither consolidates you get duplicate URLs. It doesn't matter which format you pick; it matters that you pick one and enforce it with 301 redirects (the strong signal), backed by canonical tags, consistent internal links, and sitemap entries. Watch the file-path gotcha (page.html/ won't load), the REST API quirk (many frameworks treat /resource and /resource/ as distinct routes), double slashes, and redirect chains stacking with HTTPS/www. And per my usual advice: unless your setup is causing issues, I wouldn't force a change to your URLs.

TL;DR — example.com and example.com/ are identical — the root domain is the only universal rule. Everywhere else /page and /page/ are distinct URLs, so both-live-and-unconsolidated means duplicate URLs. It doesn’t matter which format you pick; enforce one with a 301 redirectA 301 redirect is the HTTP status code for a permanent move: it tells browsers and search engines a URL has moved for good, and it's the strongest signal for consolidating a page's ranking signals onto the new URL. Google says permanent redirects don't cause a loss in PageRank. (the strong canonicalizationHow search engines pick one canonical URL among duplicates and consolidate signals onto it. signal — trailing slashA trailing slash is the forward slash (/) at the end of a URL — example.com/page/ versus example.com/page. Except at the bare root domain, the two versions are different URLs to search engines, so you pick one format and enforce it. is just one of ~40), backed by a canonical tagA rel=\"canonical\" annotation — in the HTML <head> or an HTTP Link header — that tells search engines which URL is the preferred version of duplicate or near-duplicate content. when a redirectA redirect sends browsers and crawlers from a requested URL to a different one. An HTTP redirect specifically is a 3xx status code paired with a Location header; meta refresh and JavaScript redirects achieve a similar navigation without being a 3xx response themselves. Permanent redirects (301/308) are Google's signal the target should be canonical; temporary ones (302/303/307) aren't. isn’t feasible, plus consistent internal linksAn internal link is a hyperlink from one page on a website to another page on the same website. Internal links help search engines discover your pages and pass ranking signals (PageRank and anchor-text context) between them. and sitemapA sitemap is a file that lists the pages, images, videos, and other files on your site so search engines can discover them. It helps discovery, but submitting a sitemap doesn't guarantee crawling or indexing. entries. Mind the file-path gotcha (page.html/ is a distinct, server-dependent path), the REST API quirk (frameworks like Flask can treat /resource and /resource/ as different routes), double slashes (legal but can confuse crawlersA crawler — also called a spider or bot — is an automated program that fetches web pages, extracts their links, and queues new URLs to visit. Search engines use crawlers to discover and download content for their index.), and redirect chainsA → B → C instead of A → C. Each hop loses link equity and adds latency. stacking with HTTPSHTTPS is the encrypted version of HTTP — it uses TLS to authenticate the server and protect data in transit between a browser and a website. Google announced it as a lightweight ranking signal in 2014 and today conditionally prefers HTTPS pages as canonical; Chrome marks plain HTTP pages 'Not Secure.'/www hops. My standing advice holds: unless it’s causing a problem, don’t force a change.

Evidence for this claim Google treats slash and non-slash URLs as separate URLs, either of which can be canonical if behavior is consistent. Scope: Google's documented trailing-slash handling. Confidence: high · Verified: Google Search Central Blog: To slash or not to slash Evidence for this claim Under URI resolution rules, a trailing slash changes path-base semantics; server behavior still determines the HTTP resource returned. Scope: URI reference resolution, distinct from search-engine canonical choice. Confidence: high · Verified: IETF RFC 3986: Reference resolution

What a trailing slash is (and where it came from)

A trailing slash is the forward slash at the end of a URL. As I put it in my Ahrefs trailing slash guide, “A trailing slash is a forward slash (”/”) placed at the end of a URL such as domain.com/ or domain.com/page/.”

The slash used to mean something specific. In the past, a folder would have a trailing slash and a file would be without the trailing slash — the slash was the server’s way of saying “this is a directory, a container of other things,” as opposed to a single file like index.html. That distinction is largely historical now: these days, URLs in most systems aren’t pointing to files. The URL is a record stored in a database. Your CMSA content management system (CMS) is software that lets users create, manage, and publish digital content — like blog posts and pages — without writing raw code. WordPress, Drupal, and Joomla are the most common open-source CMS platforms. routes /blog/trailing-slash/ to a database row, not to a folder on a hard drive, so the directory-vs-file semantics have mostly dissolved into a formatting convention.

But the convention died while the underlying server behavior that produced it did not — which is where the gotcha below comes from.

The one universal rule: the root-domain exception

Here’s the single rule that’s true everywhere: the trailing slash on the bare root domain is irrelevant. example.com and example.com/ are the same URL.

This isn’t an SEO nicety; it’s how HTTP works. A request for a homepage is technically a request for / — the slash after the hostname is always there, even when your browser hides it in the address bar. John Mueller has framed this as the root’s trailing slash being implicitly present and implied for canonicalizationHow search engines pick one canonical URL among duplicates and consolidate signals onto it., so https://example.com is functionally https://example.com/ for Google’s purposes. There’s nothing to redirect at the root because there’s no second URL — they’re one and the same resource. My own plain-language version of the same rule: domain.com = domain.com/“These URLs are treated exactly the same and it doesn’t matter which version you use.”

Everywhere else, that equivalence evaporates.

Everywhere else, it’s genuinely a different URL

The moment there’s a path after the domain, the slash is a real part of the URL. As I wrote in the guide: for every case besides the trailing slash directly after the root domain, a trailing slash will be treated as a separate URL. So example.com/shoes and example.com/shoes/ are two distinct addresses.

If both load the same content and neither consolidates to the other, you’ve manufactured a duplicate-URL situation — the exact kind of thing the canonicalization sibling in this cluster exists to sort out. In most real setups this isn’t catastrophic, because a self-referencing canonical tagA rel=\"canonical\" annotation — in the HTML <head> or an HTTP Link header — that tells search engines which URL is the preferred version of duplicate or near-duplicate content. or Google’s own duplicate handling usually picks a preferred version. But “usually” isn’t “always,” and leaving it to chance means you’re relying on Google to guess correctly instead of telling it.

The gotcha that survived: don’t slash a real file

The file-vs-directory meaning faded, but the mechanical behavior didn’t. In most cases, if you add a trailing slash to a file such as .html, .php, .js, .css, .pdf, .jpg, etc., it won’t load the file. Mueller’s illustrative version of this is https://www.google.com/humans.txt versus https://www.google.com/humans.txt/ — appending a slash to an actual file path produces a different URL that typically won’t resolve to the file (it 404s or is otherwise mishandled). So while “add a trailing slash everywhere” sounds like a tidy rule, it breaks on any URL that ends in a real filename — which is exactly why the server-config rules below have to be file-aware.

REST APIs are a different story

Almost every trailing-slash article assumes a CMS front-end, where /page and /page/ serve the same content and the only question is which one to consolidate to. That assumption breaks for REST APIs.

Many API frameworks treat /resource and /resource/ as genuinely distinct routes with different behavior — not duplicate views of one thing. Flask is the clearest documented example: define a route with a trailing slash and requesting the no-slash version auto-redirects to the slash version; define it without a trailing slash and requesting the slash version returns a 404 rather than redirecting, unless you explicitly relax that with strict_slashes=False. Express, Django REST Framework, and others have their own conventions and toggles. The point for developer-adjacent readers: don’t assume your CMS’s slash-forgiveness applies to your API layer. A headless setup can have a slash-tolerant front end sitting on top of a slash-strict API, and the two failure modes look nothing alike — one is an SEO duplicate-content story, the other is a hard 404 in your app.

Pick a format and enforce it — redirect first, canonical as backup

The honest answer to “slash or no slash?” is that it doesn’t matter which you pick. Whether you choose to use a trailing slash or not is more of a personal preference than anything. Google’s reps have said the same thing for years: the best solution is to be consistent and only use one version of a URL — link to that version, redirect to it, use it in sitemapsA sitemap is a file that lists the pages, images, videos, and other files on your site so search engines can discover them. It helps discovery, but submitting a sitemap doesn't guarantee crawling or indexing., use it for rel-canonical. “Consistent” is the operative word. Every canonicalization signal should agree:

  • Internal linksAn internal link is a hyperlink from one page on a website to another page on the same website. Internal links help search engines discover your pages and pass ranking signals (PageRank and anchor-text context) between them. all use the chosen format.
  • Sitemap lists only the chosen version.
  • Canonical tags point at the chosen version.
  • Redirects send the other version to the chosen one.

On which signal does the heavy lifting: a redirect is far stronger than a bare canonical tag. Trailing slash is just one of the many canonicalization signals Google weighs — Gary Illyes has put the count at over twenty, and by 2025 Google was talking about roughly forty (I walk through the full list in my canonicalization guide). Crucially, Illyes said a 301 redirectA 301 redirect is the HTTP status code for a permanent move: it tells browsers and search engines a URL has moved for good, and it's the strongest signal for consolidating a page's ranking signals onto the new URL. Google says permanent redirects don't cause a loss in PageRank., or any sort of redirect actually, should be much higher weight when it comes to canonicalization than whether the page is on an http URL or httpsHTTPS is the encrypted version of HTTP — it uses TLS to authenticate the server and protect data in transit between a browser and a website. Google announced it as a lightweight ranking signal in 2014 and today conditionally prefers HTTPS pages as canonical; Chrome marks plain HTTP pages 'Not Secure.'.” And Google is explicit that a canonical tag is a hint, not a rule — it “may choose a different page as canonical than you do.” So: redirect when you can; fall back to canonical only when you genuinely can’t (shared hosting with no server-config access, a CDN/edge setup that doesn’t support rewrites, or a legacy system where both versions must stay independently reachable).

Enforcing it in server config

The single most important implementation detail — and the thing most copy-paste snippets get wrong — is that your rule has to be file-aware and directory-aware, so it doesn’t try to strip the slash off a real directory or bolt one onto a real file. My Apache rules use !-d (not a directory) and !-f (not a file) guards for exactly that reason; the Nginx and IIS equivalents below carry the same logic. Full copy-pasteable snippets for both directions on all three servers are in the Scripts tab.

The other detail that’s easy to miss: a “remove the trailing slash” rule also has to exclude the bare root. A request for your homepage is a request for / — strip the slash there with a naive ^(.*)/$ pattern and the rule matches its own output, redirecting / to /. That’s a same-URL 301, and depending on the server and client it can loop instead of resolving. Since the root is the one place a slash never matters anyway (see above), just carve it out of the rule explicitly rather than relying on it happening to fail to match. And whatever engine you’re on, let the substitution pass the original query string through unchanged — don’t drop ?utm_source=... or similar off the back of a slash redirect.

  • Apache.htaccess with mod_rewrite, using the !-d / !-f guards.
  • Nginx — a rewrite ... permanent rule (or return 301), with try_files handling real files/directories.
  • IIS — the URL Rewrite module, expressed as <rule> blocks in web.config.

Whichever server you’re on, do both directions of the decision in one rule so you’re not stacking hops (more on that under pitfalls).

CMS and platform defaults

Most people never touch server config because their platform already picks a format — you just want to know what it picked and standardize on it.

  • WordPress adds a trailing slash by default with the standard “Post name” permalink structure. You control it under Settings > Permalinks: as I note in the guide, /%postname%/ would add the trailing slash to URLs /%postname% would remove the trailing slash from URLs.” Change the custom structure and it retroactively changes your site-wide format — which is a URL change, with all the usual risk.
  • Other platforms vary. Shopify, Squarespace, Wix, and various static-site generators each have their own default and their own (sometimes limited) ability to change it. Don’t assume — check yours, then make your internal links, canonicals, and sitemap match whatever the platform actually emits.

Common pitfalls

A few failure modes that show up alongside trailing-slash inconsistency:

  • The self-referencing-canonical trap. The generic advice that “every page should have a self-referencing canonical” gets SEOs in trouble when a developer makes both the slash and non-slash version self-canonical — each pointing at itself — instead of having one redirect or canonicalize to the other. Two pages each declaring “I’m the canonical” defeats the entire purpose. One of them needs to point at the other.
  • Double slashes (//). A buggy redirect rule that adds a slash without checking whether one already exists can produce example.com//page/. Per RFC 3986 that’s technically legal — Illyes put it as “From a puritan perspective, that’s not an issue… the forward slash is a separator and is OK to appear in the URL path as many times as you like.” But he immediately added: “From a usability perspective it’s probably not the greatest idea, and it may also confuse some crawlersA crawler — also called a spider or bot — is an automated program that fetches web pages, extracts their links, and queues new URLs to visit. Search engines use crawlers to discover and download content for their index..” Avoid them.
  • Redirect chainsA → B → C instead of A → C. Each hop loses link equity and adds latency.. Trailing-slash redirects love to stack with your other canonicalization redirects — HTTP→HTTPS, non-www→www (or the reverse), and casing. A single request can end up hopping through three or four 301s before it lands. Each hop costs a little crawl efficiency and adds latency. Resolve all the canonicalization dimensions (protocol, host, slash, case) in one redirect where your server config allows it, and update internal links to point at the final URL so you’re not relying on the redirect at all.
  • Cross-engine strictness. Independent testing has found Bing tends to crawl and index only one version of a slash/no-slash pair, while Google will crawl both and filter one — so slash inconsistency can surface differently across engines. Treat that as a reason to be tidy, not as an official Bing rule.

A few myths worth killing

  • “There’s a right slash format for SEO.” There isn’t — except at the root, where it doesn’t matter at all. Consistency beats choice.
  • “A trailing slash always means directory today.” Historical. Most URLs are database records now, though servers can still be configured to behave the old way (which is why file paths still misbehave when you slash them).
  • “Inconsistency automatically halves your rankings/link equity.” Unsourced. The accurate version is that duplicate URLs split signals across two addresses instead of consolidating onto one — a real effect, but not a literal 50/50 law.
  • “A canonical tag is enough; you don’t need a redirect.” Canonical is a hint Google can override; a 301 is a much stronger signal. Redirect when you can.

Should you change your existing URLs? Usually not.

TIP Test the slash rule as part of the complete redirect path

Check both variants and record every hop. A clean result should reach the chosen HTTPS and host version directly, without stacking separate protocol, host, case, and slash redirects.

Trace each variant with my free Redirect Checker Free

  1. Test a representative directory-style URL with and without the trailing slash.
  2. Repeat for a file-looking URL so the rule does not append a slash to a real asset.
  3. Update the rewrite rule and internal links, then confirm each non-preferred variant takes one hop to the final URL.

If your site already works and you’re just tidying for tidiness’ sake, my answer is the same one I give for URL changes generally: “There’s always a risk with changes, so unless your setup is causing issues I wouldn’t try to force a change to your URLs.” Changing your slash format site-wide is a full URL migration — every URL 301s, internal links need updating, and there’s always some reprocessing cost and risk of botched redirects. That’s worth it if you have a genuine problem (both versions indexed and fragmenting a page, a slash-strict API 404ing users, a messy chain of redirects). It’s not worth it to make your URLs “look right.” Set new sites up consistently from day one; leave working sites alone.

This topic sits right next to its siblings in the website-structure cluster — url-structure (its parent, where trailing slash is one section of the broader picture), canonicalization (the machinery that resolves duplicate slash variants), site-architecture, and website-structure. They’ll link up automatically.

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.