The lighttpd way:
With config file, I only know about 404 errors. To send a "non implemented" response, you may use lighttpd mod Magnet (and install LUA), then:
In the config file:
$HTTP["host"] =~ "api\.mydomain\.com$" {
$HTTP["scheme"] == "http" {
magnet.attract-physical-path-to = ("/path/to/501.lua")
}
}
Note that "/path/to/501.lua" should be readable by lighttpd. Then in the 501.lua file:
lighty.content = { { filename = "/path-to-your/501.html" } }
lighty.header["Content-Type"] = "text/html"
return 501
Very hard to just send a 501... right ?
The alternative way:
If you already have a dinamic language pluged with fastcgi, etc, you can implement error responses (lets say, 501.php) that does what the .lua script makes:
- Send the proper http response (feasible on any "web" language)
- Print the proper headers (feasible on any "web" language)
- Print the proper html or template or static file (feasible on any "web" language)
And use them where needed.