rsnext/examples/rewrites/next.config.js
Robin Tom 1a34b237b6
Example for Rewrites (Custom routes) (#15403)
This PR adds example for #15073  
> - [ ] `rewrites` For [docs/api-reference/next.config.js/rewrites.md](https://github.com/vercel/next.js/blob/canary/docs/api-reference/next.config.js/rewrites.md)
2020-07-25 02:38:58 +00:00

29 lines
663 B
JavaScript

module.exports = {
async rewrites() {
return [
{
source: '/team',
destination: '/about',
},
{
source: '/about-us',
destination: '/about',
},
// Path Matching - will match `/post/a` but not `/post/a/b`
{
source: '/post/:slug',
destination: '/news/:slug',
},
// Wildcard Path Matching - will match `/news/a` and `/news/a/b`
{
source: '/blog/:slug*',
destination: '/news/:slug*',
},
// Rewriting to an external URL
{
source: '/docs/:slug',
destination: 'http://example.com/docs/:slug',
},
]
},
}