Hoe alle 404-pagina's om te leiden naar de homepagina?

I’m migrating my WordPress blog to Discourse. Now due to different link structure, there will be tons of 404 pages after the migration. I can’t set a redirect for each one of them manually, so I need a solution to do that automatically.