Context: I have a blog with a good amount of content indexed by Google. For example, all the content is indexed as www.site.com/post1. I am migrating my blog to NextJS and I have scoped the blog posts to www.site.com/blog/post1. I was able to easily use the redirects with 301 to maintain the SEO for these blog posts. However, I am running into an issue where links like www.site.com/sitemap.xml are also redirected to www.site.com/blog/sitemap.xml. Is there a way to redirect only if the pattern doesn't match some path? Here is my section on redirects in next.config.js
async redirects() {
return [
{
source: '/:slug',
destination: '/blog/:slug',
permanent: true// Matched parameters can be used in the destination
},
{
source: '/sitemap.xml',
destination: '/sitemap.xml',
permanent: false// Matched parameters can be used in the destination
}
]
}