N
Nuxt3mo ago
yashwp

How to create a permanent redirection on several old routes?

Hi, I've a nuxt app, hosted on Vercel. Route 53 is dns manager. There are some old URLs that Google Search Console is scraping, which are not removed or names are changed to new names. for example: OLD URL - domain.com/flagship NEW URL - domain.com/flagship-with-seo-keywords GSC is somehow scrapping old url also, so I want to redirect all the traffic coming from the old URL to the NEW URL via 301. Now I need to know how can I add such permanent redirections. so the GSC stops coming 404, instead, count such URLs as redirected to NEW. Basically, Best way to do so
2 Replies
Single
Single3mo ago
Create the old page and add a redirect here:
definePageMeta({
redirect: 'flagship-with-seo-keywords'
})
definePageMeta({
redirect: 'flagship-with-seo-keywords'
})
Nevermind, this doesn't really answer you question as this is an internal redirect and does not return a 301. I am not familiar with Vercel, but Cloudflare does support setting 301 forwardings. I assume Vercel should have such an option too somewhere.
Patrity
Patrity3mo ago
You can use the routeRules object in your nuxt config: https://nitro.unjs.io/config#routerules
routeRules: {
'/flagship': { redirect: { to:'/flagship-with-seo-keywords', statusCode: 301 } },
}
routeRules: {
'/flagship': { redirect: { to:'/flagship-with-seo-keywords', statusCode: 301 } },
}