d640590907
The code here should contain a regex path matching example, as stated in the comment; but it is the same as the wildcard path matching example above. https://nextjs.org/docs/api-reference/next.config.js/redirects#regex-path-matching
34 lines
902 B
JavaScript
34 lines
902 B
JavaScript
module.exports = {
|
|
// Uncomment the line below to enable basePath, pages and
|
|
// redirects will then have a path prefix (`/app` in this case)
|
|
//
|
|
// basePath: '/app',
|
|
|
|
async redirects() {
|
|
return [
|
|
{
|
|
source: '/team',
|
|
destination: '/about',
|
|
permanent: false,
|
|
},
|
|
// Path Matching - will match `/old-blog/a`, but not `/old-blog/a/b`
|
|
{
|
|
source: '/old-blog/:slug',
|
|
destination: '/news/:slug',
|
|
permanent: false,
|
|
},
|
|
// Wildcard Path Matching - will match `/blog/a` and `/blog/a/b`
|
|
{
|
|
source: '/blog/:slug*',
|
|
destination: '/news/:slug*',
|
|
permanent: false,
|
|
},
|
|
// Regex Path Matching - The regex below will match `/post/123` but not `/post/abc`
|
|
{
|
|
source: '/post/:slug(\\d{1,})',
|
|
destination: '/news/:slug',
|
|
permanent: false,
|
|
},
|
|
]
|
|
},
|
|
}
|