lighttpd mod_rewrite with file exists check
lighttpd is a web server that is high performance and has a small memory footprint. On some of my servers I'm really low on both CPU and free memory. The web server I currently 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 aternative 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).
UPDATED: 1 Feb. Bug reported by Frieder Schüler with -NF rewrites being ignored. Found and fixed. Please download the new copy.
You can find a copy of the code here: mod_rewrite.c
Here it is compiled under Debian on Intel to run in /usr/local/lib:
mod_rewrite.so and mod_rewrite.la
