Lighttpd 1.5 rewrite rules for WordPress
GreatWebGuy.com is now running on Lighttpd or "Lighty" 1.5 and WordPress 2.2. The biggest hurdle we had to overcome running our blog with the Lighty http server was the rewrite rules for our custom Permalink structure - /%category%/%postname%/ - none of the rewrite rules posted on the web seemed to work correctly. If you get the rules right, you should be able to accomplish the pretty urls that you want with 5 or fewer rewrite rules, I've seen some examples on the web with as few as 4 and as many as 30. We also ran into problems with the version numbers included in the querystring of the internal javascript urls in WordPress, it turned out they were being rewritten unintentionally.
These may work or not for your setup, a couple of things to note when writing rewrite rules:
- Start your rule set with areas you know need to be excluded, not rewritten, and write rules that result in => "$0"
- Work your way from specific rules to more generic and all encompassing rules
- Attempt to break the rules down into as few rules as possible, realize rule interpretation causes load on the http server
- Use rewrite-once so that Lighty will stop processing rules when it's found a match
url.rewrite-once = ( "^/(wp-.+).*/?" => "$0", "^/(sitemap.xml)" => "$0", "^/(xmlrpc.php)" => "$0", "^/keyword/([A-Za-z_0-9\-]+)/?$" => "/index.php?keyword=$1", "^/.*?(\?.*)?$" => "/index.php$1" )
Upgrades complete at GreatWebGuy, we’re back now and posting
We're still here, just been too busy to blog, it's been a month, but we've done a lot.
First and foremost we found a new host and at a great price. We opted for a VPS at JTLNet, for $19.95/mo. we get 15GB of disk space, 256MB of guaranteed memory, 200GB of bandwidth and the ability to install any software we want. We wouldn't recommend this setup to anyone that doesn't know what they're doing, but it's a great alternative to a dedicated server. The guys at JTLNet are top notch, many a night we've opened support tickets at 1 a.m. because we hit one roadblock or another and they're there and on top of the issue within an hour.
Having the freedom to pick your own software and not be bound to what your host is running is a beautiful, yet time consuming, thing. I've swapped out the Apache web server for Lighttpd (Lighty) 1.5, the mod_decompress module in Lighty has reduced our page sizes by 85%. For those that don't know, Lighty is a lightweight web server that serves up PHP via FastCGI faster than Apache using mod_php, it's still in Beta but so far it seems stable enough and pretty quick. We upgraded our PHP version to 5.1.2 and MySQL to 5.27 to gain any performance improvements the newer versions are bound to have. Last but not least we migrated to WordPress 2.2 and added some Ajax goodness to the site, notice as you click around we're no longer refreshing the entire page, but just the post content.
All in all things are running smoothly now, not to say we didn't hit several hurdles upgrading and migrating to a new server and platform. We'll be sharing the details of the upgrades and our troubles in our upcoming posts.