agaskar.com

Super simple Drupal clean URLs with lighttpd.

Agaskar.com runs lighttpd to squeeze the most it can out of a tiny 64M VPS (which, believe it or not, Drupal 6.x can run on -- I usually have about 2-4M free at any given time, and probably could've had a bit more had I chosen a 32-bit architecture instead of a 64-bit one!) I've been meaning to turn on clean urls on agaskar.com for awhile, but everything I'd read about drupal clean urls with lighttpd seemed to be a bit of a hack (redirecting a 404 to the index.php page) or reputedly didn't work perfectly.

This URL rewrite solution using a LUA script, however, seems to work great and only took 5 minutes to drop in. Read on to learn about the minor changes to these instructions I made in order to get it working on my server.

I made two changes to work with the dir structure here; instead of this config recommended by morphir.com:

$HTTP["url"] =~ "^/drupal-5.1" {
# we only need index.php here.
index-file.names = ( "index.php" )
# for clean urls
magnet.attract-physical-path-to = ( "/etc/lighttpd/drupal.lua" )
}

I used this config, which redirects the agaskar.com and www.agaskar.com domains to the proper drupal directory (Yeah, I also need to make agaskar.com the canonical URL):

 
$HTTP["host"] =~ "(^|\.)agaskar\.com$" {
  server.document-root = "/var/www/agaskar.com/drupal"
  # we only need index.php here.
  index-file.names = ( "index.php" )
  # for clean urls
  magnet.attract-physical-path-to = ( "/etc/lighttpd/drupal.lua" )
  }

After that, I simply changed the provided drupal.lua script so that the local_prefix var was blank (because /var/www/agaskar.com/drupal is my root dir) like so:

local prefix = ''

After these changes I was able to load up the Drupal clean URLs admin page and enable clean urls using the form.