Redirect rules are not processed

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

For besserschlafen.de:

[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.

Hey @iliquifysnacks,

It might be because you have a 404 page. For besserschlafen.de, you may need to force the rules by using 302! instead of 302.

Failing this, you may want to read our redirects support guide.

Let me know if this helps!

Hi @Pieparker,

thanks for the hint. If I add the “!”, the toml file isn’t parsed correctly. Is that normal?

If I use force = true it still does not process any redirect rules

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”?


Jon

In my build log there are no redirect rules processed.

Cool! Well that’s a good place to start :grin: Not having any rules processed like:

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


Jon

Well it sees some info from the toml file, so i guess it is read. See this screenshot:

Huh. Yeah that’s really interesting. Clearly the build process is picking up the toml file and running with it :thinking:. 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


Jon

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…

Hey @iliquifysnacks,

It’s not unheard of that the netlify.toml is read but redirects are ignored. There may be a syntax error somewhere in the file which caused the error.

If this reoccurs, please let us know!