Customizing your 404 error page with Lighttpd

Create a file called error-handler.html in the root directory of the server (the one you refer to as ‘/’) and make an entry in your lighttpd.conf file:

## error-handler for status 404
server.error-handler-404 = “/error-handler.html”

Advanced options:

If you use a particular scrpting language on your site (php, perl, cgi, fast-cgi, etc.) you can name your error-handler with the appropriate file extension:

## error-handler for status 404
#server.error-handler-404 = “/error-handler.html”
#server.error-handler-404 = “/error-handler.php”
#server.error-handler-404 = “/error-handler.pl”
#server.error-handler-404 = “/error-handler.cgi”
#server.error-handler-404 = “/error-handler.fcgi”

Tip: Copy the entire block above into your lighttpd.conf and uncomment the one appropriate line by removing the leading “#” symbol.

After making all your changes, restart lighttpd and test your new error handler by visiting an incorrect URL.

Have any other Lighttpd error handling tips? Leave a comment below.