如何将所有404页面重定向到主页?

You can handle all broken 404 pages to the home page or another page using the “Customize” feature.
Go to the section Customize > Themes > Create New Theme > name your theme ex 404 Redirect and set the Base Theme to Default.
Then create the new theme > Edit CSS/HTML. In the HTML section, create a JavaScript snippet that will handle the redirection.
Past this code.

<script type="text/discourse-plugin">
  api.onPageChange((url, title) => {
    // Redirect to the home page for all 404 pages
    if (url.includes('/404')) {
      window.location.href = '/';
    }
  });
</script>

Please adjust your page name according to your need. Read this redirect old url to new discourse url