Home > Enterprise >  Redirecting only subpaths in vercel.json? (Next.js)
Redirecting only subpaths in vercel.json? (Next.js)

Time:04-25

Changing the structure of my site and am trying to redirect everything behind /blog to /. So /blog/some-blog-post should now go to /some-blog-post. I am doing this:

    {
        "source": "/blog/:path*",
        "destination": "/:path*"
    },

This works.

However, I want to keep my blog overview page at /blog. This breaks now though? How can I redirect everything behind blog back to root, but keep /blog?

CodePudding user response:

You should remove the star in the end of the path, since it probably makes the path slug optional, meaning that the rule also applies to just /blog/ path as well.

  • Related