Skip to main content

Why is Alias needed in ErrorDocument directive?

Comments

6 comments

  • cPanelMichael
    Hi Matt, Can you verify where exactly you are setting up those entries at? Is this in a .htaccess file or in an Apache include file? Thank you.
    0
  • ItsMattSon
    Hi @cPanelMichael, Those were put in Service Configuration > Apache Configuration > Include Editor > Pre VirtualHost Include (All Versions). When the full path didn't work, I tried with the Alias and it worked no problem. I changed it back to see if it was just dumb luck but then it would go back to saying (on a 404 page for example) "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request". Not sure why :p
    0
  • cPanelMichael
    Hi Matt, Apache is configured to first look for a custom error page in the document root of the website (e.g. /home/username/public_html/404.shtml). You noted the use of the following custom entry with the full path: ErrorDocument 404 /usr/local/apache/htdocscustom/404.shtml
    Thus, as I understand, your custom entry leads to Apache searching for the custom error page at the following location: /home/username/usr/local/apache/htdocscustom/404.shtml That location doesn't exist by default so it won't load. By adding the Alias entry, the request goes to the correct location. Thank you.
    0
  • ItsMattSon
    Hi Matt, Apache is configured to first look for a custom error page in the document root of the website (e.g. /home/username/public_html/404.shtml). You noted the use of the following custom entry with the full path: ErrorDocument 404 /usr/local/apache/htdocscustom/404.shtml
    Thus, as I understand, your custom entry leads to Apache searching for the custom error page at the following location: /home/username/usr/local/apache/htdocscustom/404.shtml That location doesn't exist by default so it won't load. By adding the Alias entry, the request goes to the correct location. Thank you.

    Hi @cPanelMichael, Thanks! Makes sense, but can you confirm it is true since I have the / before the path? (ie. /usr) so shouldn't that start at the root level? (if the / wasn't there, what you said would make perfect sense though)
    0
  • cPanelMichael
    Hello, That's the same behavior I see on a test environment, even when using the full path as you described. Apache excepts the path from the document root of the website that's accessed, not the full path to the file on the server. The alias entry works because it's adding that alias entry to all virtual hosts on the server. Thank you.
    0
  • ItsMattSon
    Ahh, brilliant explanation. Thanks @cPanelMichael. The world makes sense again!
    0

Please sign in to leave a comment.