I have attempted to utilize a rewrite rule in the NextJS next.config.js file in order to redirect URLs containing '/lite' to '?amp=1', however, it does not seem to be functioning correctly in all scenarios.
Below is the code from my next.config.js:
async rewrites() {
return [
{
source: '/:articles/:slug/:id/lite/',
destination: '/:articles/:slug/:id/?amp=1',
}
];
},
}
module.exports = nextConfig
The rewriting works as expected for the URL:
https://localhost:3000/article/trending/us-man-witnesses-his-kidney-transplant-procedure-indian-origin-surgeon-viral-photos-9415947/
However, it fails for the URL:
https://localhost:3000/article/trending/trending-globally/us-man-witnesses-his-kidney-transplant-procedure-indian-origin-surgeon-viral-photos-9415947/
If anyone can provide assistance with this issue, I would greatly appreciate it. Thank you.