The issue lies with configuring redirects using netlify.toml or _redirects file in Gatsby project

I’m having trouble setting up any redirects using netlify.toml or _redirects.

Currently, my netlify.toml configuration looks like this:

[[redirects]]
  from = "/oferta"
  to = "/new-path"
  status = 301
  force = false
  query = {path = ":path"}
  conditions = {Language = ["en"], Country = ["US"], Role = ["admin"]}

However, the redirection from “jakas-domena.pl/oferta” to “jakas-domena.pl/new-path” isn’t working. The file is visible in the Netlify build files.

My current file structure in the project before the build, in the development state, looks like this:

node_modules
src
static
.env
.gitignore
gatsby-browser.js
gatsby-config.js
gatsby-node.js
netlify.toml <- netlify file is here
package-lock.json
package.json
README.md

Please help me because I know how to do redirects from this level, and adding caching like _headers is essential for optimizing and working with the project.

Why have you added query and conditions? Do you need those?

"Hi Hrishikesh,

I don’t need query = {path = ":path"}. I can shorten this redirect to:

tomlCopy code

[[redirects]]
  from = "/oferta"
  to = "/new-path"
  status = 301
  force = true

And that won’t work properly."

Thanks for following up and providing this info! Can you please share the name of the site you’re having issues with so that we can look into this further?