Hi, I have multiple netlify sites and usually there is no problem defining redirects in the netlify.toml file. For my site https://sleep.ink redirects are processed, but the ones at besserschlafen.de are not. Here is the content of both toml files for comparison:
sleep.ink
[build]
base = "/"
publish = "frontend/public/"
command = "yarn netlify-prod"
functions = "frontend/functions"
environment = { YARN_FLAGS = "--frozen-lockfile" }
[context.production]
command = "yarn netlify-prod"
[context.deploy-preview]
command = "yarn netlify-preview"
[context.branch-deploy]
command = "yarn netlify-preview"
[[plugins]]
package = "netlify-plugin-gatsby-cache"
[[redirects]]
from = "/produkt/ink/"
to = "/schlafdrink"
status = 301
[[redirects]]
from = "/vskfreesvnnghts"
to = "https://sleep-ink.myshopify.com/cart/30980542890080:1?discount=vskfreesvnnghts"
status = 301
[[redirects]]
from = "fnfrorbttvrznnchte"
to = "https://sleep-ink.myshopify.com/cart/30980536500320:1?discount=fnfrorbttvrznnchte"
status = 301
[[redirects]]
from = "zhnerotzwnzgn"
to = "https://sleep-ink.myshopify.com/cart/30980536533088:1?discount=zhnerotzwnzgn"
status = 301
[[redirects]]
from = "bunte-deal2"
to = "/schlafdrink"
status = 301
[build]
base = "web"
command = "npm run build"
publish = "public"
[[plugins]]
package = "netlify-plugin-gatsby-cache"
[[redirects]]
from = "/privacy-policy"
to = "https://www.iubenda.com/privacy-policy/39071544"
status = 302
[[redirects]]
from = "/3164859.html"
to = "https://www.schlafdrink.de/3164859.html"
status = 302
I can’t spot a difference that would explain why netlify is finding redirect rules for one but not the other.
Yeah - an ! is the force = true for the _redirects file format, but since you’re using the netlify.toml format, you’d want to use the force = true flag instead of !
Aside from that syntax bit, I checked out what I could in your site. My initial conclusion is that I agree - your redirect rules look fine and manually hitting those endpoints does not result in the 302 that it should. Something’s up here.
One other question - in your build log does it show “2 redirect rules processed”?
Indicates something’s wrong! (Duh Jon, we knew that)
Another hinting question - can you share with me some of the build log for the site? I want to make sure that the build is actually using the build command in the netlify.toml rather than any command you may have put in the UI interface. The build log should be very clear if it’s using the UI build command or a build command from the netlify.toml
Huh. Yeah that’s really interesting. Clearly the build process is picking up the toml file and running with it . Your redirects toml syntax looks fine too… so I’m a bit perplexed. You don’t also have a _redirects file too do you? Or did you in the past with this project? I’ve never actually tried having both but maybe they’re not playing well together.
Can you also try clearing the build cache then building, just for the sake of trying everything? Under Deploys => Trigger Deploy
I have not worked with _redirects files in the past. There are also none in the current version. Yesterday the redirects started to be processed again, although I didn’t change anything in the repo. Very mysterious…