Instead of an error page / 404 I want to just show the /sitemap page. Of course I don\'t want a redirect and I still want the 404 HTTP response header to be set.
Is
The easiest way is to create this file:
/app/Resources/TwigBundle/views/Exception/error404.html.twig/templates/bundles/TwigBundle/Exception/error404.html.twig... and copy this line into it:
{{ render(controller('App\\Controller\\HomepageController::index')) }}
That's it. This will show the home page with a 404 status code. It only works in prod environment (clear the cache!), since in dev and test Symfony always shows its exception page.
References: