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.
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`:
@@ -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`:
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):
```jsfilename="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`: