Redirects in netlify.toml are broken

The last redirect in my netlify.toml file does absolutely nothing:

[[redirects]]
  from = "/*"
  to = "/.netlify/builders/avatar"
  status = 200
  force = true

[[redirects]]
  from = "https://luminous-granita-25aeac.netlify.app/*"
  to = "https://favicon-fetcher.galexia.agency/:splat"
  status = 301
  force = true

The Netlify build UI says it has successfully passed 2 redirect rules. The 1st is working as expected, the second doesn’t do anything. I read this article Redirect netlify site to main domain - #4 by jen talking about Netlify automatically setting link headers, but that isn’t set.

The reason the second one never works is because the first one is a wildcard (/*) and a wildcard redirect catches everything.

As stated under Rule processing order documentation

The redirects engine will process the first matching rule it finds, reading from top to bottom. Rules in the _redirects file are always processed first, followed by rules in the Netlify configuration file.

The solution is to change the order of the redirects so the wildcard is last. Remember that if you add any more redirects they need to go in front of the wildcard.

As for Netlify automatically setting link headers this only applies to the primary/secondary domain, and not to the YOURSITE.netlify.app domain. E.g. if example.com is set a the primary domain then www.example.com will automatically redirect to example.com.

Thank you very much. That’s fixed it for me.