redirect config for certain slugs
Unanswered
Masai Lion posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Masai LionOP
Hi all, I can't quite figure out why my next.config.js redirects aren't working 😅. I'm forwarding old blog post URLs to the new URL but need to ignore any trailing
Basically
Here's what my next.config.js currently looks like this:
/amp
.Basically
'/old/blog-slug'
and '/old/blog-slug/amp'
both to '/new/blog-slug'
. Unfortunately, I also have a handful of special cases which go to various other places. To deal with these cases, I'm using regex but it seems to mess up the overall redirecting?Here's what my next.config.js currently looks like this:
async redirects() {
return [
{ // redirect old/manual-one
source: '/old/:path(manual-one.*)',
destination: '/other/manual-one',
permanent: true,
},
{ // redirect old/manual-two
source: '/old/:path(manual-two.*)',
destination: '/special/manual-two',
permanent: true,
},
{ // redirect old/blog-slug/amp
source: '/old/:path((?!manual-one.*|manual-two.*).*)/amp',
destination: '/new/manual-one',
permanent: true,
},
{ // redirect old/blog-slug
source: '/old/:path((?!manual-one.*|manual-two.*).*)',
destination: '/new/blog-slug',
permanent: true,
},
]
},