Project

General

Profile

conditional configuration documentation

Added by dmrzzz almost 5 years ago

First of all, thanks for a great product! I have one suggestion for the documentation: as a new user, I spent a long time trying to do things like this:

$HTTP["host"] == "www.example.com" {
  # Rewrite one specific URL under www.example.com
  url.rewrite-once = (
    "^/specificURLToRewrite" => "/specificTarget" 
  )
}

# Any request not rewritten yet will get rewritten here (I WISH)
url.rewrite-once = ( ".*" => "/capture$0" )

in the hope that the second rule would also apply to requests for www.example.com as long as they did not match the pattern "^/specificURLToRewrite" (this seemed consistent in my mind with the documented description of url.rewrite-once). In fact other URLs for www.example.com do not get rewritten at all by the above config.

Today I had an epiphany: any given option (e.g. url.rewrite-once) only gets one value for each request being handled; the value set within an applicable conditional replaces (i.e. obscures) any value set in global context for the same option.

In retrospect this seems perfectly sensible, maybe even "obvious", but it took me a fair bit of stumbling around to figure it out, and I think the reason why is that http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_Configuration doesn't specifically address what happens when the same option is configured both in global context and within a conditional.

I'm not confident enough in my conclusions to edit the wiki myself, but a sentence or two in the docs specifically clarifying this (from someone who knows for sure) would be awesome. Bonus points for also covering the case where the same option is set within two different conditionals that might both match the same request.

Thanks!


Replies (1)

RE: conditional configuration documentation - Added by gstrauss over 1 year ago

Thanks, dmrzzz. You intuition is correct.

My attempt at explaining lighttpd config merging can be found at: https://redmine.lighttpd.net/boards/2/topics/6541

    (1-1/1)