lighttpd mod_rewrite with file exists check
Update: 5 Sep 2008. The code was considerably cleaned up by Lucas Aerbeydt.
lighttpd is a web server that has high performance and a small memory footprint. On some of my servers I'm really low on both CPU and free memory. The web server I used to use, Apache, is quite large so I thought I test out lighttpd.
On top of the web server I run Drupal as my content manager and use Drupal's standard Apache conditional rewrite rules to make the two inter work well.
lighttpd can do rewrites but lacks the conditional test in its module, mod_rewrite.
There is a suggested solution which involves using an alternative module, mod_magnet, and using that to load in an interpreted programming language call "lua". But that seemed to have a high performance hit. So I modified a copy of mod_rewrite to support a new pair of options: url.rewrite-repeat-NF and url.rewrite-once-NF. These only apply the rewrite if the file corresponding to the URI does NOT exist in the Filestore (NF = Not Filestore).
Here is the source for this enchanced mod_rewrite.c
