We at 619Cloud are huge fans of lighttpd web server instead of the traditional web server apache. In fact, we run lighttpd for our site, and recommend it to clients over apache as much as possible and when appropriate.
Lighttpd has shown superior performance in regards to serving static content (javascript, css, html), and uses fast-cgi for processing server side content such as php. Additionally, lighttpd has a significantly lower memory footprint than apache and scales extremely well, while apache becomes a memory bog when traffic increases. When running any type of cloud hosting (virtual private servers), every megabyte of memory is critical, and the more you can squeeze out, the better.
The biggest problem, and pain point for most users and system administrators making the switch to lighttpd, is how to replicate mod_rewrite rules of apache and .htaccess files. Specifically, most users and system administrators want to replicate the wordpress structure of permalinks using mod_rewrite.
Unfortunately, lighttpd does not support .htaccess files natively, and the lighttpd version of mod_rewrite syntax is a bit different than apache.
Never fear though. We have a set of lighttpd mod_rewrite rules that we use our self, and for our clients specifically tailored for wordpress with lighttpd.
- First include a reference to a separate lighttpd rewrite rule configuration file in your main lighttpd.conf file (usually /etc/lighttpd/lighttpd.conf). This is not required, but we like to break apart the main lighttpd configuration directives from the custom rewrite rules to keep things nice and tidy.
# Include custom rewrite rules include "/etc/lighttpd/rewrite_rules.conf"
- Create the custom rewrite rules configuration file (/etc/lighttpd/rewrite_rules.conf) and place the following lines in it:
1 2 3 4 5 6 7 8 9 10 11 12
$HTTP["host"] =~ "(^|\.)mydomain\.com$" { url.rewrite-once = ( # Exclude additional specific directories from rewrites "^/(custom-js)/?(.*)" => "$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 mydomain.com to be your domain name of course. The (^|\.) at the start handles the case of www and no www. Excluding the custom-js directory is optional, but we at 619Cloud have a few custom javascript files that we use, and thus we need to exclude that directory from rewrites. Most people won’t have to exclude additional custom directories, but we showed how if you need it.
- Make sure you have the module mod_rewrite installed and uncommented in your main lighttpd configuration file (usually /etc/lighttpd/lighttpd.conf).
- Finally, give lighttpd a restart to apply the changes and the new custom mod_rewrite rules.
That is it! Make sure you remember to restart lighttpd and you should be on your way using wordpress with permalinks and lighttpd.




I really enjoyed this post, especially the “examples in this post” portion which made it really easy for me to SEE what you were talking about without even having to leave the article. Thanks
I could think of a few other things I’d like to do to it too
Also ich bin total von der Seite beeindruckt, super klasse!! : D
Hi
Seems good but how about having 100 wordpress blog on a lighttpd server? I mean we have got 100 addon domains. Then what will be the content of /etc/lighttpd/rewrite_rules.conf?
Many thanks
Concon dokundu
Wow this post saves me. Clean, simple, and it works!
By the way, is there any performance impact implementing rewrite rules this way?
Thanks!