Skip to content

Rewrites behavior #13353

@Timer

Description

@Timer

I am using the following next config to rewrite dynamic urls to the next page pages/post/[id], which works great on my local machine (using [email protected])

// next.config.js
module.exports = {
  experimental: {
    async rewrites() {
      return [
        {
          source: '/(.*)-:id(\\d+).html',
          destination: `/post/:id`,
        }
      ]
    }
  }
}

However, when I deploy the app to vercel I get an 404 for these routes. I am further confused with vercel routes (https://vercel.com/docs/configuration#project/routes) and rewrites (https://vercel.com/docs/configuration#project/rewrites).

Which solution should be used when hosting next.js on vercel?

Originally posted by @joafeldmann in #13347

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions