diff --git a/docs/01-app/03-api-reference/03-file-conventions/proxy.mdx b/docs/01-app/03-api-reference/03-file-conventions/proxy.mdx index 4133cdbf3ccf2..ea9204d477e09 100644 --- a/docs/01-app/03-api-reference/03-file-conventions/proxy.mdx +++ b/docs/01-app/03-api-reference/03-file-conventions/proxy.mdx @@ -122,6 +122,7 @@ Configured matchers: 2. Can include named parameters: `/about/:path` matches `/about/a` and `/about/b` but not `/about/a/c` 3. Can have modifiers on named parameters (starting with `:`): `/about/:path*` matches `/about/a/b/c` because `*` is _zero or more_. `?` is _zero or one_ and `+` _one or more_ 4. Can use regular expression enclosed in parenthesis: `/about/(.*)` is the same as `/about/:path*` +5. Are anchored to the start of the path: `/about` matches `/about` and `/about/team` but not `/blog/about` Read more details on [path-to-regexp](https://github.com/pillarjs/path-to-regexp#path-to-regexp-1) documentation. diff --git a/docs/01-app/03-api-reference/05-config/01-next-config-js/headers.mdx b/docs/01-app/03-api-reference/05-config/01-next-config-js/headers.mdx index 55550b8061d04..d76842be40fbc 100644 --- a/docs/01-app/03-api-reference/05-config/01-next-config-js/headers.mdx +++ b/docs/01-app/03-api-reference/05-config/01-next-config-js/headers.mdx @@ -75,7 +75,7 @@ module.exports = { ## Path Matching -Path matches are allowed, for example `/blog/:slug` will match `/blog/hello-world` (no nested paths): +Path matches are allowed, for example `/blog/:slug` will match `/blog/first-post` (no nested paths): ```js filename="next.config.js" module.exports = { @@ -99,6 +99,12 @@ module.exports = { } ``` +The pattern `/blog/:slug` matches `/blog/first-post` and `/blog/post-1` but not a nested path like `/blog/a/b`. Patterns are anchored to the start, `/blog/:slug` will not match `/archive/blog/first-post`. + +You can use modifiers on parameters: `*` (zero or more), `+` (one or more), `?` (zero or one). For example, `/blog/:slug*` matches `/blog`, `/blog/a`, and `/blog/a/b/c`. + +Read more details on [path-to-regexp](https://github.com/pillarjs/path-to-regexp) documentation. + ### Wildcard Path Matching To match a wildcard path you can use `*` after a parameter, for example `/blog/:slug*` will match `/blog/a/b/c/d/hello-world`: diff --git a/docs/01-app/03-api-reference/05-config/01-next-config-js/redirects.mdx b/docs/01-app/03-api-reference/05-config/01-next-config-js/redirects.mdx index 0c167ff43afad..7110868c65450 100644 --- a/docs/01-app/03-api-reference/05-config/01-next-config-js/redirects.mdx +++ b/docs/01-app/03-api-reference/05-config/01-next-config-js/redirects.mdx @@ -56,7 +56,7 @@ When `/old-blog/post-1?hello=world` is requested, the client will be redirected ## Path Matching -Path matches are allowed, for example `/old-blog/:slug` will match `/old-blog/hello-world` (no nested paths): +Path matches are allowed, for example `/old-blog/:slug` will match `/old-blog/first-post` (no nested paths): ```js filename="next.config.js" module.exports = { @@ -72,6 +72,12 @@ module.exports = { } ``` +The pattern `/old-blog/:slug` matches `/old-blog/first-post` and `/old-blog/post-1` but not `/old-blog/a/b` (no nested paths). Patterns are anchored to the start: `/old-blog/:slug` will not match `/archive/old-blog/first-post`. + +You can use modifiers on parameters: `*` (zero or more), `+` (one or more), `?` (zero or one). For example, `/blog/:slug*` matches `/blog`, `/blog/a`, and `/blog/a/b/c`. + +Read more details on [path-to-regexp](https://github.com/pillarjs/path-to-regexp) documentation. + ### Wildcard Path Matching To match a wildcard path you can use `*` after a parameter, for example `/blog/:slug*` will match `/blog/a/b/c/d/hello-world`: diff --git a/docs/01-app/03-api-reference/05-config/01-next-config-js/rewrites.mdx b/docs/01-app/03-api-reference/05-config/01-next-config-js/rewrites.mdx index 981db9b701745..a35f901c0fce7 100644 --- a/docs/01-app/03-api-reference/05-config/01-next-config-js/rewrites.mdx +++ b/docs/01-app/03-api-reference/05-config/01-next-config-js/rewrites.mdx @@ -163,7 +163,7 @@ module.exports = { ## Path Matching -Path matches are allowed, for example `/blog/:slug` will match `/blog/hello-world` (no nested paths): +Path matches are allowed, for example `/blog/:slug` will match `/blog/first-post` (no nested paths): ```js filename="next.config.js" module.exports = { @@ -178,6 +178,12 @@ module.exports = { } ``` +The pattern `/blog/:slug` matches `/blog/first-post` and `/blog/post-1` but not `/blog/a/b` (no nested paths). Patterns are anchored to the start: `/blog/:slug` will not match `/archive/blog/first-post`. + +You can use modifiers on parameters: `*` (zero or more), `+` (one or more), `?` (zero or one). For example, `/blog/:slug*` matches `/blog`, `/blog/a`, and `/blog/a/b/c`. + +Read more details on [path-to-regexp](https://github.com/pillarjs/path-to-regexp) documentation. + ### Wildcard Path Matching To match a wildcard path you can use `*` after a parameter, for example `/blog/:slug*` will match `/blog/a/b/c/d/hello-world`: