Bootstrap FreeKB - Apache (Web Server) - ErrorDocument directive (401 404 500)
Apache (Web Server) - ErrorDocument directive (401 404 500)

Updated:   |  Apache (Web Server) articles

The ErrorDocument directives in the web servers configuration file (e.g. httpd.conf) can be used to serve custom HTML pages for certain HTTP response codes, such as 404 Not Found. By default, the ErrorDocument directives are commented out. With the ErrorDocument directives commented out, something like this will be displayed.

 

One simple option is to simply use the ErrorDocument directive to display something a bit more meaning.

ErrorDocument 404 "HTTP Response Code 404 (Not Found)"

 

Or, you could return your own fancy HTML page. Your own HTML file will need to be placed somewhere below the DocumentRoot directory. For example, if the DocumentRoot directory is /usr/local/html/docs, then your own HTML file could reside at /usr/local/html/docs/404.html. 

DocumentRoot /usr/local/html/docs
ErrorDocument 404 /404.html

 

Now, if a user requests a file from your web server that returns 404 Not Found, your fancy HTML page will be returned.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a629dd in the box below so that we can be sure you are a human.