Skip to content
This page is also available as Markdown: request this page's URL with an Accept: text/markdown header. For an index of Next.js documentation, see /docs/llms.txt.

skipTrailingSlashRedirect

Last updated September 7, 2026

Enabling skipTrailingSlashRedirect turns off the automatic redirects that add or remove a trailing slash. You handle any redirecting you still want in Proxy.

Most projects don't need this option. It is one of the advanced Proxy flags, meant for specific routing cases and debugging.

next.config.ts
import type { NextConfig } from 'next'
 
const nextConfig: NextConfig = {
  skipTrailingSlashRedirect: true,
}
 
export default nextConfig

Reference

By default, Next.js redirects every request so the trailing slash matches your trailingSlash setting.

trailingSlashRequestDefault response
false/about200
false/about/308 redirect to /about
true/about308 redirect to /about/
true/about/200

Enabling skipTrailingSlashRedirect affects both server responses and client-side navigation:

  • Both /about and /about/ return 200. Neither redirects to the other.
  • Next.js stops changing trailing slashes during client-side navigation. <Link> and router URLs keep the path exactly as written.

Your own redirects and rewrites from next.config.js still apply.

Paths that contain a dot

If the last path segment contains a dot, Next.js treats the path as a file and removes the trailing slash, regardless of the trailingSlash setting. A dot in an earlier segment has no effect, except under .well-known/, which is exempt from the default redirects when trailingSlash is true.

RequesttrailingSlash: truetrailingSlash: falseskipTrailingSlashRedirect: true
/about308 redirect to /about/200200
/about/200308 redirect to /about200
/gcc.git/308 redirect to /gcc.git308 redirect to /gcc.git200
/version/1.2.3/308 redirect to /version/1.2.3308 redirect to /version/1.2.3200
/version/1.2.3/my-page/200308 redirect to /version/1.2.3/my-page200
/.well-known/x/200308 redirect to /.well-known/x200

With skipTrailingSlashRedirect enabled, none of these redirects are generated and every path is served at whichever form was requested.

Good to know

  • Keep setting trailingSlash as you did before. It still controls the URLs Next.js generates and the output filenames for output: 'export'.
  • With output: 'export', this preserves the href instead of resolving /me to /me/. See Static Exports.
  • Serving one page at both /about and /about/ gives search engines two URLs for it. Set a canonical URL in your metadata, or redirect in Proxy.

Examples

Handling trailing slashes in Proxy

With skipTrailingSlashRedirect enabled, Next.js no longer adds trailing slashes, but Proxy can still add them selectively. This example adds a trailing slash to your own routes while leaving a set of legacy prefixes untouched, which makes an incremental migration easier.

proxy.ts
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
 
const legacyPrefixes = ['/docs', '/blog']
 
export default function proxy(request: NextRequest) {
  const { pathname } = request.nextUrl
 
  if (legacyPrefixes.some((prefix) => pathname.startsWith(prefix))) {
    return NextResponse.next()
  }
 
  // Apply trailing slash handling, skipping files and `.well-known` paths
  if (
    !pathname.endsWith('/') &&
    !pathname.match(/((?!\.well-known(?:\/.*)?)(?:[^/]+\/)*[^/]+\.\w+)/)
  ) {
    return NextResponse.redirect(new URL(`${pathname}/`, request.nextUrl))
  }
}

Version History

VersionChanges
v13.1.0skipTrailingSlashRedirect added.

Was this helpful?

supported.