#redirect to middle slug parameter

1 messages · Page 1 of 1 (latest)

steady tulipBOT
#

Hi @rugged saddle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

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:

  • source is the incoming request path pattern, in this case /first/second/third.
  • destination is the path you want to route to, in this case /second.
  • permanent is a boolean that, if true, will use the 308 status code which instructs clients/search engines to cache the redirect forever. If false, 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