rsnext/docs/api-reference/next.config.js/trailing-slash.md
Jan Potoms 2142b76e6b
Normalize trailing slashes (#13333)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-06-23 13:38:49 +02:00

1,004 B

description
Configure Next.js pages to resolve with or without a trailing slash.

Trailing Slash

Warning

: This feature is experimental and may not work as expected. You must enable the trailingSlash experimental option to try it.

By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. For example /about/ will redirect to /about. You can configure this behavior to act the opposite way, where urls without trailing slashes are redirected to their counterparts with trailing slashes.

Open next.config.js and add the trailingSlash config:

module.exports = {
  experimental: {
    trailingSlash: true,
  },
}

With this option set, urls like /about will redirect to /about/.