Next.js Discord

Discord Forum

Redirect not working next.config.js

Answered
Palomino posted this in #help-forum
Open in Discord
PalominoOP
I'm fairly new to nextjs. I'm having an issue where I have a redirect in the next.config.js file but it's not working. It's not going to the destination url.
Is this an issue with the parenthesis in the source url?

const nextConfig = {
  async redirects() {
    return [
      {
        source: "/douglas-pollina(p)-symington",
        destination: "/douglas-pollina-symington",
        permanent: true,
        statusCode: 301
      }
    ]
  }
}
Answered by riský
yeah parenthesis are an issue as its thinking regex mode, but you should be able to escape them and it should work \\(p\\)

https://nextjs.org/docs/app/api-reference/next-config-js/redirects#regex-path-matching
View full answer

4 Replies