Support Forums

NextJS , redirect , how to remove the query parameter?


I was using the next.config.js but then I read your documentation and moved everything to netlify.toml . The redirect do work but my goal is to do this redirect:

/page?foo=bar => /page/bar

but I am getting this instead:

/page?foo=bar => /page/bar?foo=bar

What I have done today:

from = "/page"
to = "/page/:bar"
status = 301
force = true
query = {foo = ":bar"}

How can I solve this ?

Hi @leoB,

Netlify passes query parameters in redirects and there’s no option to disable that.

What would could do is change URLs with history.pushState() once the page loads.