Set up Redirects for Netlify and Vercel

· 3 mins

Tiếng Việt - Vietnamese Version

Let's say you recently changed your blog path from /articles/* to /blog/*. This will impact your SEO on search engines and the links where you had shared before if you don't have a redirect rule for this situation. You could get all the paths for your posts and set a rule for each of them, but that wouldn't be necessary. Instead, you could set a rule to apply to all.


On Netlify, you could either use netlify.toml file or _redirects file set the redirect rule.

For netlify.toml, the rule should look like this:

from = "/articles/*"
to = "/blog/:splat"
status = 301

And here is how it looks in _redirects:

/articles/*  /blog/:splat  301


For Vercel, we're gonna use vercel.json:

  "redirects": [
    { "source": "/articles/(.*)", "destination": "/blog/$1", "statusCode": 301 }
> comment on threads / twitter
> cd ..