Technical SEO

Trailing slash SEO: pick one form, redirect the other, and make every layer agree

/about and /about/ are two URLs to Google. Neither form ranks better; what hurts is serving both, or having two layers that each redirect the other way. Framework defaults, server config and a curl test.

By SEOFix TeamPublished Updated
1,494 words · 7 min readMarkdown
Trailing slash SEO: pick one form, redirect the other, and make every layer agree

For SEO, it doesn't matter whether your URLs end in a slash. It matters that each page answers at one form only. Google treats /about and /about/ as two different URLs: "Google treats each URL above separately (and equally) regardless of whether it's a file or a directory, or it contains a trailing slash or it doesn't contain a trailing slash" (Google Search Central Blog, "To slash or not to slash", checked 2 November 2026). If both answer 200, you have a duplicate for every page. The fix is the one Google gives in the same post: "Use a 301 redirect from the duplicate to the preferred version", with rel="canonical" as the fallback when you can't redirect.

The root URL is the exception. Per the same post, https://example.com and https://example.com/ are equivalent, so there's nothing to fix on the homepage.

What goes wrong with trailing slashes

There are three patterns, in order of how often they cause real damage.

1. Both forms answer 200. Common on static hosts, custom Node servers and apps where someone turned off the framework's redirect. Google crawls both, picks one as canonical, and splits link signals between them until it does. On a large site it doubles the URL inventory Google has to work through (crawl budget).

2. Two layers redirect in opposite directions. The app strips the slash, nginx or a CDN rule adds it. The result is a redirect loop, and Search Console reports "Redirect error".

3. The site redirects, but everything else uses the other form. The server redirects /jobs/ to /jobs, while canonicals, sitemaps, hreflang and internal links still say /jobs/. Every internal click and every sitemap URL costs a redirect, and the canonical points at a URL that redirects. Nothing is broken, but every signal disagrees with the server.

Check what your site does

Request both forms of a deep URL and look at the status and Location:

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

Healthy output has one 200 and one 301 or 308 pointing to it:

https://www.example.com/jobs/dubai  200 ->
https://www.example.com/jobs/dubai/  308 -> https://www.example.com/jobs/dubai

Two 200s means pattern 1. Then check that the redirect doesn't stack on top of others. curl -sIL prints every hop:

curl -sIL http://example.com/jobs/dubai/ | grep -iE '^(HTTP|location)'

If that shows http → https, then apex → www, then the slash, you have a three-hop chain. Redirect chains covers flattening it, and www vs non-www covers the host part.

Finally, check what the page itself claims:

curl -s https://www.example.com/jobs/dubai | grep -io '<link[^>]*rel="canonical"[^>]*>'

The canonical should match the form that answers 200, exactly.

Which form to pick

Neither ranks better. Google says it has no preference, and notes that with redirects "our search results will likely show the version of the URL with the 200 response code". Pick:

  • whatever your site already uses, if it's consistent. Switching forms on an established site is a URL migration for every page;
  • your framework's default on a new site, so you never fight it;
  • with slash if you generate a static export to directories (/about/index.html), where the directory URL is the natural address of each page.

Files are different. Nobody expects /sitemap.xml/ or /report.pdf/, and Next.js, for example, exempts paths that look like files from its slash rules.

Framework defaults

StackDefaultStatusSetting
Next.jsNo slash: /about/ redirects to /about308trailingSlash: true flips it
WordPressFollows the permalink structure301Settings → Permalinks
Laravel (default .htaccess)No slash, unless the path is a real directory301public/.htaccess
Apache, directoriesAdds the slash to real directories (DirectorySlash On)301DirectorySlash Off
nginxNo rule; both forms reach your appn/arewrite or return

Next.js

"By default Next.js will redirect URLs with trailing slashes to their counterpart without a trailing slash", and trailingSlash: true reverses that (Next.js trailingSlash):

// next.config.js
module.exports = {
  trailingSlash: true, // /about -> 308 -> /about/
}

The skipTrailingSlashRedirect docs list the exact behaviour: with the default, /about/ gets a 308 redirect to /about; with trailingSlash: true, /about gets a 308 to /about/. A last path segment containing a dot is treated as a file, so /version/1.2.3/ loses its slash under either setting. .well-known/ paths are exempt when trailingSlash is true.

skipTrailingSlashRedirect: true turns the redirects off entirely, and then both forms return 200. The Next.js docs warn about the consequence themselves: "Serving one page at both /about and /about/ gives search engines two URLs for it." Only use it if something else (Proxy, your CDN) does the redirect.

Write redirects() destinations, canonicals and sitemap URLs in the same form as your trailingSlash setting. A destination of /footwear/ with the default setting produces a second hop to /footwear.

WordPress

WordPress's redirect_canonical() "Redirects incoming links to the proper URL based on the site url", including trailing slashes according to the permalink structure (WordPress developer reference). A structure of /%postname%/ gives slash URLs; /%postname% gives none. It doesn't run for searches, feeds, admin URLs or POST requests. Problems usually come from a plugin, a hard-coded link in a theme, or a server rule in front that disagrees with the permalink setting.

Laravel

The default public/.htaccess in a new Laravel app strips trailing slashes with a 301, unless the path is a real directory (laravel/laravel):

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

.htaccess is read only by Apache. A Laravel app served by nginx doesn't get this rule, and both forms reach the router. Add the nginx rule below.

Server config

nginx: remove the trailing slash

# server {} block: /jobs/dubai/ -> /jobs/dubai (root "/" is not matched)
location ~ ^(.+)/$ {
    return 301 $1$is_args$args;
}

nginx picks the longest matching prefix location, then checks regular expressions in order and uses the first that matches (nginx location). So this regex wins over your normal location / block and catches every path ending in / except the root (a prefix location marked ^~ would still win). If you serve real directories with index files (a static export, a /docs/ folder), exclude them first, or use the add-slash version instead.

An equivalent with rewrite, where the permanent flag "returns a permanent redirect with the 301 code" (nginx rewrite module):

rewrite ^/(.+)/$ /$1 permanent;

nginx: add the trailing slash

# /jobs/dubai -> /jobs/dubai/ ; skips anything with a dot in the last segment (files)
rewrite ^([^.]*[^/])$ $1/ permanent;

Apache: remove or add

Removing (outside Laravel), in .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

Adding:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.[a-zA-Z0-9]{1,5}$
RewriteRule ^ %{REQUEST_URI}/ [L,R=301]

Set the code explicitly. Apache's plain Redirect directive sends a 302 unless you say otherwise: temp "Returns a temporary redirect status (302). This is the default" (mod_alias). A temporary redirect is a weak canonical signal.

Apache's mod_dir adds a slash to requests for real directories by default (DirectorySlash On, mod_dir). If your no-slash rule and a real directory share a name, they will fight. Rename the directory or exclude the path.

Normalise in one layer only

Most trailing slash loops come from two layers that both have an opinion. A typical stack has four: CDN, web server, framework, CMS. Pick one to own the slash, usually the framework because it also generates your links, and remove the rule from the others. Then combine the slash with the scheme and host redirects so any variant reaches the final URL in one hop.

After the change:

  1. Re-run the curl checks on a page from each template, plus the http:// and apex variants.
  2. Update internal links, canonicals, hreflang and sitemap URLs to the chosen form. Google's canonicalization guide treats redirects and rel="canonical" as strong signals and sitemap inclusion as a weak one. They should all point the same way.
  3. Purge the CDN cache. 301 and 308 responses are "heuristically cacheable" (RFC 9110), so an old rule can outlive its config.

Finding slash mismatches across a site

A crawl finds what curl on five URLs won't: the footer link, the sitemap generator or the hreflang block that still uses the other form. SEOFix treats /page and /page/ as two URLs, so a mismatch shows up as an internal link to a redirect, a redirect chain, a canonical that points to a redirect, or a sitemap URL that isn't 200. Each issue names the URL to use instead (links and redirects checks, indexability checks).

FAQ

Is a trailing slash better for SEO? No. Google has no preference. Consistency is what counts: one form answers 200, the other redirects to it.

Should I switch an existing site to the other form? Only if you have a real reason, such as moving to a framework with the opposite default. Every URL changes, so treat it like a site migration: permanent redirects, updated links and sitemaps, and monitoring afterwards.

Is a canonical tag enough without a redirect? It works, and Google calls it "a strong option", but both URLs stay crawlable and users can still share either one. Redirect when you can.

Does case matter too? Yes. The URI standard treats scheme and host as case-insensitive, but other parts "are assumed to be case-sensitive" (RFC 3986), so /Jobs and /jobs are two URLs for the same reason /jobs and /jobs/ are.

SEOFix lists every internal link, canonical and sitemap entry that points at the wrong form of a URL, grouped by template. Your first audit is free, up to 500 pages.

ShareXLinkedIn