Mike
Mike

Reputation: 7704

Conditional Lighttpd configuration based on request headers

Is it possible to conditionally configure Lighttpd based on custom request headers?

It's possible to do so by IP address (and other variables):

$HTTP["remoteip"] ==  "0.0.0.0" {
    // Do something
}

Is there something similar for request headers, for example:

$HTTP["X-Some-Header"] ==  "Value" {
    // Do something
}

I don't think there is looking through documentation and searching Google, but perhaps somebody knows a way.

Thanks

Upvotes: 7

Views: 2111

Answers (2)

rkian
rkian

Reputation: 98

You can do this with with Lighttpd from 1.4.6 onwards, see https://redmine.lighttpd.net/projects/1/wiki/docs_configuration

In my case it looks something like:

$REQUEST_HEADER["Content-Type"] == "application/rdf+xml" { 
    url.redirect = ( "^/somewhere/(.*)$" => "/somewhere-else" ) 
}

Upvotes: 1

Mike
Mike

Reputation: 7704

Following more searching I'm pretty confident that this isn't possible.

For me the solution was to change my application.

Upvotes: 3

Related Questions