My site is returning a 404 error for users who have tried to access a restricted page. I understand that this can be seen as a useful security features, however, I would like to return a 403 error instead.

I note that drupal is recording "access denied" in the logs, but somehow this is getting converted to a 404 for the user.

I have tried changing theme to see if that helps, and had no success. I have also removed custom 404 and 403 pages but this did not help either.

Googling the problem found the following file, drupal/core/lib/Drupal/Core/Controller/ExceptionController.php. This does not seem to exist in my installation of drupal.

I am not confident (or competent!) at altering php files.

Any help that can be provided would be greatly appreciated, as I am at a loss on how to proceed.

  • Which pages return 404? Is this on a fresh drupal install or what steps you need to reproduce this?
    – 4uk4
    Aug 23, 2017 at 6:31
  • This is on all pages with access requirements. Either pages restricted to certain roles, or Group pages for non-group members. 404s are returned when the user does not have the required access rights for those pages. This is not a fresh install, I have several modules running - all from the drupal modules portal. No custom modules.
    – tomf
    Aug 23, 2017 at 7:15
  • Then this is probably a (unwanted) feature of a module you've installed. You can look in the module configuration if you can switch it off.
    – 4uk4
    Aug 23, 2017 at 7:51

1 Answer 1


I've found a workaround using the "redirect 403 to login" module. It is not yet in alpha for D8, but seems pretty stable.

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.