404 redirects not working or conflicting

I have the following _redirects file, and all redirects are working as expected. However, the 404 redirects are not working, which is still available if you directly visit https://example.com/en-ch/404/. I’ve added comments for each line prefixed with “//////”.

Also, in the following, I’ve deliberately written “https:/example.com” instead of “https://example.com” because the forum doesn’t allow me to post more than 6 links in one topic.

////// https:/example.com/hello -> https:/example.com/de-ch/hello if German language
/* /de-ch/:splat 302 Language=de-ch

////// https:/example.com/ -> https:/example.com/de-ch/ if German language
/ /de-ch/ 302 Language=de-ch

////// https:/example.com/de/hello -> https:/example.com/de-ch/hello
/de/* /de-ch/:splat 302

////// https:/example.com/de-ch/error -> https:/example.com/de-ch/404/
/de-ch/* /de-ch/404/ 404

////// https:/example.com/hello -> https:/example.com/en-ch/hello if English language
/* /en-ch/:splat 302 Language=en-ch

////// https:/example.com/ -> https:/example.com/en-ch/ if English language
/ /en-ch/ 302 Language=en-ch

////// https:/example.com/en/hello -> https:/example.com/en-ch/hello
/en/* /en-ch/:splat 302

////// https:/example.com/en-ch/error -> https:/example.com/en-ch/404/
/en-ch/* /en-ch/404/ 404

////// https:/example.com/hello -> https:/example.com/en-ch/hello for other languages
/* /en-ch/:splat 302

////// https:/example.com/ -> https:/example.com/en-ch/ for other languages
/ /en-ch/ 302

hi there, before we dig in, did you see this brand new guide on debugging redirects?

I strongly suggest you give it a thorough read through and see if this fixes your problem:

if not, please post again, and we’ll try and troubleshoot.