My website is changing URL structure and I have 1000s of pages. For SEO I would like to set up a Regex redirect in my next.config.js file, but the official documentation doesn't really help my case because my pages have the following structure:
/product-name-price/
The new structure will be:
/price/product-name
UPDATE:
I've managed to get /product-name-price to redirect to /price/product-name-price with the following changes to next.config.js:
async redirects() {
return [
{
source: '/:product',
destination: '/price/:product',
permanent: true,
}
]
}
How do I manipulate the :product parameter within the next.config.js file to exclude the -price part of product-name-price so that my final url will be /price/product-name?