Drupal clean urls and lighttpd

If you are using lighttpd as webserver and host drupal websites you probably have used some lua script and mod_magnet to get clean urls. Recent versions of lighttpd (1.4.26+) are able to handle rewrites better through the url.rewrite-if-not-file command. The config for your [virtual] server should look like this:

# deny access to drupal files
url.access-deny = ( "~", ".inc", ".engine", ".install", ".module", ".info", ".sh", ".sql", ".theme", ".tpl.php", ".xtmpl", "Entries", "Repository", "Root" )
# define rewrite rules
url.rewrite-if-not-file = ( "^/([^\?]+)(\?(.*))?" => "/index.php?q=$1&$3" )

With this you should be set. No more fiddeling with mod_magnet which was especially painful if you were running multiple drupal sites on lighttpd.

Jens Grassel Written by:

Solving problems and burning chrome for fun and profit.