How does the 404 page you can define in /admin/config/system/site-information work?

I found Drupal\system\Controller\Http4xxController->on404(), but how does that display whatever path I definied in basic site settings?

I'm trying to deliver a 410 when a page is deleted. I hve a database table with deleted paths, an InboundPathProcessorInterface to call a custom controller. Now I want to output the exact same thing as a 404, just with another status code.

Alternativly, how do I get the content of a given system path (i.e. node/123) to output in a Symfony\Component\HttpFoundation\Response?

1 Answer 1


For the configured custom path:


   public function on404(GetResponseForExceptionEvent $event) {
    $custom_404_path = $this->configFactory->get('system.site')->get('page.404');
    if (!empty($custom_404_path)) {
      $this->makeSubrequestToCustomPath($event, $custom_404_path, Response::HTTP_NOT_FOUND);

If no custom path is configured the subrequest is built for '/system/404' pointing to the controller you've mentioned:


  public function on404(GetResponseForExceptionEvent $event) {
    $this->makeSubrequest($event, '/system/404', Response::HTTP_NOT_FOUND);

To customize other status codes than 403 or 404 extend DefaultExceptionHtmlSubscriber and override on4xx().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.