I've been fighting with Lighttpd for the past few days and I think I've finally won. The problem was that I had old hosts hanging around the web from when KangarooBox first went live, and I wanted to get rid of them. And by get rid of them I mean redirect them, permanently, to the www. host. For example, the one big major FQDN that I wanted to squash is "mail.kangaroobox.com". When we were just getting the company off the ground we need to test some thing really quickly so we just grabbed the first host name we found (that wasn't www). It turns out that it got propagated much more widely than we had anticipated and Google got it's hands on it. :(

So now, thanks to the following bit of configuration code, everything seems to be working really well. I post this so that future generations may learn from my mistakes. Or I'm just following the Linus creed: "Backups are for wimps. Real men upload their data to an FTP site and have everyone else mirror it." :)


## Redirect to www.kangaroobox.com for SEO
$HTTP["host"] !~ "^www.kangaroobox.com" {
url.redirect = (
"^/(.*)" => "http://www.kangaroobox.com/$1"
)
}
## Rewrite the URL for sapphire
$HTTP["host"] =~ "^www.kangaroobox.com" {
url.rewrite-once = (
"(?i)(/.*\.([A-Za-z0-9]+))(.*?)$" => "$0",
"^/(.*?)(\?|$)(.*)" => "/sapphire/main.php?url=$1&$3"
)
server.error-handler-404 = "/sapphire/main.php"
}