How to return 410 with lighttpd

Almad asked:

I have a subdomain with service I am going to kill.

I’d like to use 410 to mark it as such.

Is there a way to do that with lighttpd without resolving to mod_magnet and lua scripts?

My answer:

Set the document root to an otherwise empty directory, and use a dynamic error handler to send a 410 response.


$HTTP["host"] == "" {
  server.document-root = "/var/www/gone"
  server.error-handler-404 = "/gone.php"

Where /var/www/gone/gone.php contains something like the following:

header("HTTP/1.1 410 Gone");
header("Status: 410 Gone");

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.