Recently, we just switch over Daily Nerdy to use lighttpd web server instead of Apache. Lighttpd has shown superior performance in regards to serving static content, and uses fast-cgi for processing PHP pages. Everything went smooth and was a breeze until we tried getting nice looking permalinks for Wordpress. We tried dozens of mod_rewrite rules, but most didn’t work in every case and some flat out didn’t work at all.
Here is our mod_rewrite solution which we are currently using and have working with Wordpress 2.8.5.
1.) First include a reference to a separate lighttpd rewrite rule configuration file in your main lighttpd.conf file. This inst required, but we like to break apart the main lighttpd configuration directives from the rewrite rules.
#### Include Rewrite Rules
include “/etc/lighttpd/rewrite_rules.conf”
2.) Create the rewrite rules configuration file (/etc/lighttpd/rewrite_rules.conf) and place the following in it:
$HTTP["host"] =~ “(^|\.)dailynerdy\.com$” {
url.rewrite-once = (
# Exclude audio directory from rewrites
“^/(audio)/?(.*)” => “$0″,“^/(wp-.+).*/?” => “$0″,
“^/(sitemap.xml)” => “$0″,
“^/(xmlrpc.php)” => “$0″,
“^/keyword/([A-Za-z_0-9-])/?$” => “index.php?keyword=$1″,
“^/(.+)/?$” => “index.php/$1″
)
}
Make sure you change dailynerdy\.com to be your domain name of course. The (^|\.) at the start handles the case of www and no www. Excluding the audio directory is optional as well, but we use the Wordpress plugin Audio Player and store of all our media in that directory, so we excluded it.
Finally as a note, make sure you have the module mod_rewrite installed and uncommented in your lighttpd configuration file.


