Thursday, December 31, 2009

How to mimic apache's "!-f" and "!-d" in lighttpd

Just a while ago, I was still trying to write a php script to load static content and send them to browser, now that I know apache has a nice rewrite condition like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d<
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I don't have to use that script of mine any more. However, I hit the wall straight on when I was trying to port the same functionality in lighttpd, and the only thing I found was
Only half of the solution, and it somehow stopped working for me after working or 2 weeks, and says
WARNING: unknown config-key: url.rewrite-if-not-file (ignored)

That did it ;-) I was determined to find the right solution to finish this for good, and here is what I have found:

Using mod_magnet and a small lua script. For detail, see the following urls.

Oh, if you happen to be on ubuntu, you would probably also need to do this
sudo apt-get install lighttpd-mod-magnet

No comments: