lighttpd: weird behavior on multiple rewrite rule matches
- by netmikey
I have a 20-rewrite.conf for my php application looking like this:
$HTTP["host"] =~ "www.mydomain.com" {
url.rewrite-once += (
"^/(img|css)/.*" => "$0",
".*" => "/my_app.php"
)
}
I want to be able to put the webserver in kind of a "maintenance" mode while I update my application from scm. To do this, my idea was to enable an additional rewrite configuration file before this one. The 16-rewrite-maintenance.conf file looks like this:
url.rewrite-once += (
"^/(img|css)/.*" => "$0",
".*" => "/maintenance_app.php"
)
Now, on the maintenance page, I have a logo that doesn't get loaded. I get a 404 error. Lighttpd debug says the following:
2012-12-13 20:28:06: (response.c.300) -- splitting Request-URI
2012-12-13 20:28:06: (response.c.301) Request-URI : /img/content/logo.png
2012-12-13 20:28:06: (response.c.302) URI-scheme : http
2012-12-13 20:28:06: (response.c.303) URI-authority: localhost
2012-12-13 20:28:06: (response.c.304) URI-path : /img/content/logo.png
2012-12-13 20:28:06: (response.c.305) URI-query :
2012-12-13 20:28:06: (response.c.300) -- splitting Request-URI
2012-12-13 20:28:06: (response.c.301) Request-URI : /img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.302) URI-scheme : http
2012-12-13 20:28:06: (response.c.303) URI-authority: localhost
2012-12-13 20:28:06: (response.c.304) URI-path : /img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.305) URI-query :
2012-12-13 20:28:06: (response.c.349) -- sanatising URI
2012-12-13 20:28:06: (response.c.350) URI-path : /img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (mod_access.c.135) -- mod_access_uri_handler called
2012-12-13 20:28:06: (response.c.470) -- before doc_root
2012-12-13 20:28:06: (response.c.471) Doc-Root : /www
2012-12-13 20:28:06: (response.c.472) Rel-Path : /img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.473) Path :
2012-12-13 20:28:06: (response.c.521) -- after doc_root
2012-12-13 20:28:06: (response.c.522) Doc-Root : /www
2012-12-13 20:28:06: (response.c.523) Rel-Path : /img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.524) Path : /www/img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.541) -- logical -> physical
2012-12-13 20:28:06: (response.c.542) Doc-Root : /www
2012-12-13 20:28:06: (response.c.543) Rel-Path : /img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.544) Path : /www/img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.561) -- handling physical path
2012-12-13 20:28:06: (response.c.562) Path : /www/img/content/logo.png, /img/content/logo.png
2012-12-13 20:28:06: (response.c.618) -- file not found
2012-12-13 20:28:06: (response.c.619) Path : /www/img/content/logo.png, /img/content/logo.png
Any clue on why lighttpd matches both rules (from my application rewrite config and from my maintenance rewrite config) and concatenates them with a comma - that doesn't seem to make any sense?! Shouldn't it stop after the first match with rewrite-once?