#redirect to middle slug parameter
1 messages · Page 1 of 1 (latest)
In Next.js, you can set up redirects by using the redirects key in next.config.js. Here's an example of how you can redirect from /first/second/third to /second:
module.exports = {
async redirects() {
return [
{
source: '/first/second/third',
destination: '/second',
permanent: true,
},
]
},
}
In this configuration:
sourceis the incoming request path pattern, in this case/first/second/third.destinationis the path you want to route to, in this case/second.permanentis a boolean that, iftrue, will use the 308 status code which instructs clients/search engines to cache the redirect forever. Iffalse, it will use the 307 status code which is temporary and is not cached.
You can find more information about this in the Next.js documentation (https://nextjs.org/docs/app/api-reference/next-config-js/redirects).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@rugged saddle kapa.ai is still learning and improving, please let us know how it did by reacting below