Tuesday, January 18, 2011

lighttpd rewrite-rules for WordPress MU

Today, someone in the channel #wordpress on freenode (see WordPress.org's IRC-page for more information about the channel) asked whether WordPress would work with lighttpd. As I am running such an installation myself, I took it up to help him, looking for rewrite-rules on the net, since my own were only for WordPress MU. I was looking for my own rules as well, which I picked up myself from somewhere, but did not find them. So I decided it might be good to post them here.
For WordPress MU, the following rewrite-rules work well:

1.$HTTP["host"] =~ "^blog.nifelheim.info" {
 2.  url.rewrite-once = (
 3.    "^/(.*)?/?sitemap.xml$" => "wp-content/blogs.php?file=sitemap.xml",
 4.    "^/(.*)?/?robots.txt$/" => "wp-content/blogs.php?file=robots.txt",
 5.    "^/(.*)?/?files/$" => "index.php",
 6.    "^/(.*)?/?files/(.*)" => "wp-content/blogs.php?file=$2",
 7.    "^/(wp-.*)$" => "$1",
 8.    "^/([_0-9a-zA-Z-]+/)?(wp-.*)" => "$2",
 9.    "^/([_0-9a-zA-Z-]+/)?(.*.php)$" => "$2",
10.    "." => "index.php"
11.  )
12.}
Please note, that at least the lines 1, 3, 4 and 6 needs to be adjusted if you try to use these rules for the single-blog WordPress (probably line 6 can be removed completely?). I cannot really say how far these rules do apply for the single-blog WordPress-installation, since I do not have one  .
For WordPress MU, only line 1 needs be changed. The lines 3 and 4 are only necessary, if you have a sitemap.xml and a robots.txt residing in you blog's file-directory, as you would for example when using MU Sitemap-Generator Plugin
If you have a better set of rules for either WordPress MU and/or WordPress, feel free to post them as comments.

0 comments:

Post a Comment

 
Design by GURU