server.error-handler-404 option


uri to call if the requested URL results in a static file not being found. It is not invoked if dynamic content, such as a fastcgi script, returns an HTTP 404 status code.

You can use a dynamic or static page for the handler. Note: if you use a static page, the server will return a 200 OK HTTP status code in the response, along with the contents of your static page. However, if you use a dynamic page, you must set the status code to 404 (or another appropriate error code such as "410 Gone") in the HTTP headers that your dynamic page generates.

Use server.errorfile-prefix instead of server.error-handler-404 if using static file error pages for 403 and 404 HTTP status codes and the HTTP status code sent in response to client should be 403 or 404 instead of 200.

Use server.error-handler (Details: dbdab5db) instead of server.error-handler-404 to catch all HTTP status >= 400 and preserve the HTTP status in the static file returned.

Default: not set


server.error-handler-404 = "/error-404.php" 

Prior Versions

Versions of lighttpd prior to 1.4.17 contained bugs in the implementation of this directive that meant a 404 status code generated from dynamic content was sent to the error handler. This prevented a 404 status code being sent from the error handler itself, which always returned status 200. If you are using an older version, and want to send a 404 status code please use server.errorfile-prefix; however, server.errorfile-prefix does not allow dynamic handlers.

See Also

Updated by gstrauss almost 6 years ago · 10 revisions