Question about redirects for fallback 404 page

Dear Netlify Team,

I’m trying to set up the custom fallback 404 page, but doesn’t work.


Redirects settings as follows, the multilingual 404 pages work fine, but the fallback 404 page doesn’t work. Am I doing something wrong?

# multilingual 404 pages.
  from = "/:lang/*"
  to = "/:lang/404.html"
  status = 404

# fallback 404 page.
  from = "/*"
  to = "/en/404.html"
  status = 404

What do you mean by “doesn’t work”? (Displays a different 404 page, redirect loop, 5xx error …)?

It probably would also help the Netlify folks to mention you are using Hugo (at least I think I recognize you from the Hugo forums and presume that is the SSG which you are using).

1 Like

Hi, I expect that the following 404 pages work.

  • /en/invalid-pageen/404.html
  • /zh-hans/invalid-pagezh-hans/404.html
  • /invalid-pageen/404.html

But the last one doesn’t use the fallback 404 page (en/404.html) defined in redirects.

I could copy the en/404.html to 404.html, but it would be nice that I’m able to define it in redirects without copying files.

What does it end up using?

It uses Netlify built-in 404. e.g.

Perhaps have a look at this suggestion

1 Like

Thanks, I already set it up (work as expected for multilingual 404), but the fallback 404 page seems not working. - not working, which I wish to fallback to use en/404.html. - works. - works.

While probably not the answer you’re looking for. the simplest thing is to duplicate the /en/404.html page to /404.html which Netlify would automatically serve for any invalid page.

Yep, it’s a workaround, but it would be nice without copying files.

The problem here is that you’re using placeholders. For example, taking your above redirects config:

And matching that with:

invalid-page now acts as the :lang placeholder. So based on your rule, Netlify tries to look for /invalid-page/404.html, and that doesn’t exist. Thus, the default 404. The solution is to explicitly define all languages instead of relying on placeholders.


Thanks for explanation.