‹ jan0sch.de

Drupal clean urls and lighttpd

2012-06-07

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.