301 domain redirect not working

Redirects are not working. Free plan.

AI bot can’t even figure it out. Support does not allow me to contact them.

What is the solution?

[[redirects]]
  from = "/*"
  to = "404.html"
  status = 404
[[redirects]]
  from = "https://example.com/*"
  to = "https://mainwebsite.com/:splat"
  status = 301
  force = true
[[redirects]]
  from = "https://example2.com/*"
  to = "https://mainwebsite.com/:splat"
  status = 301
  force = true
$ curl -I https://example.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 63823    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 OK
Accept-Ranges: bytes
Age: 0
Cache-Control: public,max-age=0,must-revalidate
Cache-Status: "Netlify Edge"; fwd=miss
Content-Length: 63823
Content-Type: text/html; charset=UTF-8
...

Domains are setup, SSLs are deployed etc. When visiting the domains I get to the website but
example.com does not redirect to mainwebsite.com

Also don’t have any _redirects file.

Great, that’s an improvement over having the AI lie with confidence…
https://answers.netlify.com/t/redirecting-to-a-sub-folder/136652
https://answers.netlify.com/t/pen-testing-in-netlify-own-hosted-website/134658

That’s not quite true, you can’t use private ‘email support’ but you still have this forum, where the majority of the questions are answered by Netlify Support.

Since you’ve used placeholder domain names example.com, example2.com and mainwebsite.com, I can’t check anything.

Best I can do…

  • The rules look ok to me
  • Check your build log, it should say the number of redirect rules it found
  • Ensure the redirect rules are deployed to example.com and example2.com
  • The documentation is here: Domain Level Redirects

It would be better if you updated your docs with working examples. Since nobody seems to have a clue how this works in practice.

The solution is that the domain redirects have to go above the 404 redirect at the top. Despite your docs claiming it will match the first redirect.

The docs does not mention any of this, regarding domain redirects need to be at the top.

The redirects engine will process the first matching rule it finds, reading from top to bottom.

This is highly incorrect, or the 404 wouldn’t block the domain redirect rule.

To be clear, I don’t work for Netlify, so I’m not going to be doing anything.

The redirect rules absolutely are processed top down, which matches the change you’ve made.
All your rules target the wildcard, but the domain level ones are more specific, so they should go first.

I didn’t mention it when I glanced at it, because I haven’t hosted with Netlify for some time, and never used the status of 404 rule myself.

That said, I’d presumed the 404 rule would have minimal impact due to only applying to paths where the page isn’t found as per the documentation.

@Jowo you can try having the 404.html redirect on root level and make sure that the netlify.toml is in the root directory.

[[redirects]]
from = “/*”
to = “/404.html”
status = 404

[[redirects]]
from = “https://example.com/*”
to = “https://mainwebsite.com/:splat
status = 301
force = true

[[redirects]]
from = “https://example2.com/*”
to = “https://mainwebsite.com/:splat
status = 301
force = true