WordPress Permalinks & mod_rewrite in lighttpd

After switching to lighttpd away from Apache I was pretty pleased with the whole process, everything seemed to be working fine, with the exception of my permalink structure. Bad news, however this can be fixed;

In your lighttpd.conf or 10-rewrite.conf enable mod_rewrite and paste the following code (you will obviously need to edit the $HTTP[“host”] portion):

$HTTP["host"] =~ "www.mark-gilbert.co.uk" {
url.rewrite-final = (
# Exclude common directories
"^/(wp-admin|wp-includes|wp-content)/(.*)" => "$0",
# Exclude root php files
"^/(.*.php)" => "$0",
# Handle permalinks and feeds
"^/(.*)$" => "/index.php/$1"

These three rules should cover every plugin and bit of functionality within the system. If you have other folders which you will need to access without any redirection (images in a separate folder etc), you have to add these names to the first rule, separated by the | characters.

Now go to Settings-> Permalinks, change Common Settings to Custom Structure and enter what you wish it to look like.

Basically, once mod_rewrite is enabled on the lighttpd server, which is done by adding the following line to the lighttpd.conf file;

server.modules += ("mod_rewrite")

This should work for you too.

2 thoughts on “WordPress Permalinks & mod_rewrite in lighttpd”

  1. thanks alot bruv. i just dropped the entire block after $HTTP[“host”] =~ {} into the config file, because i am testing from localhost, LAN etc so no domain yet (and i am just hosting one project at a time so)
    got confused because tweaking permalinks settings on wordpress misdirected me towards .htaccess. (which i just realized has nothing to do with lighttpd)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.