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, until I came across this posting on Tenable Tech Tips.

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")

Use the following re-write rule, which covers off permalinks and exclusions for other static files. the final code to insert should look like the below, with the obvious changes for your host;

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

Works like a charm and this certainly saved me a lot of time trying to figure this out.

Leave a Reply

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