I am trying to raise a custom error page for each error
Here is my directory
.htaccess
error_pages:
error_400.html
error_401.html
error_404.html
You've tagged your question php
, but used .html
in your example? If you are using PHP then you don't need separate error documents for each HTTP status. You can use the same PHP error document and check the REDIRECT_STATUS
(ie. $_SERVER['REDIRECT_STATUS']
superglobal) in order to determine the status of the error that triggered the error document.
So, your .htaccess
file would consist of:
ErrorDocument 400 /error_pages/error_handler.php
ErrorDocument 401 /error_pages/error_handler.php
ErrorDocument 404 /error_pages/error_handler.php
Reference: