This blog now runs on a Lighttpd (Lighty) webserver instead of Apache, and this means the configuration for ‘pretty URLs’ or permalinks of Wordpress doesn’t work like it used to.
(As you might have noticed, I use permalinks like /2007/02/this-is-permalink/)
Whereas Wordpress can automatically adapt the Apache .htacccess file to something like
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
it does not do anything automatically for your Lighty .conf configuration file (which is logical, since an application should not be allowed to mess with a central config file).
So what you have to use is:
- a Wordpress blog installed in the root of your (sub-) domain:
$HTTP["host"] =~ "{yourdomain}" {
var.app = "{yourdomain}"
accesslog.filename = base + "/logs/" + app + ".access.log"
server.errorlog = base + "/logs/" + app + ".error.log"
load php app
url.rewrite = (
"^/(wp-.+).*/?" => "$0",
"^/(sitemap.xml)" => "$0",
"^/(xmlrpc.php)" => "$0",
"^/(.+)/?$" => "/index.php/$1"
)
} - a Wordpress blog installed in a subfolder (e.g. /blog/)
$HTTP["host"] =~ "{yourdomain}" {
var.app = "{yourdomain}"
accesslog.filename = base + "/logs/" + app + ".access.log"
server.errorlog = base + "/logs/" + app + ".error.log"
load php app
url.rewrite = (
"^/?$" => "/blog/index.php",
"^/blog/(wp-.+)$" => "$0",
"^/blog/xmlrpc.php" => "$0",
"^/blog/sitemap.xml" => "$0",
"^/blog/(.+)/?$" => "/blog/index.php/$1"
)
}
The xmlrpc.php rule is necessary for external access (like, publishing from del.icio.us or Flickr), and the sitemap.xml file is something for Google Sitemaps.
For those stubborn visitors who always precede their URLs with www, you can also add a redirect:
$HTTP["host"] =~ "www.blog.forret.com" {
url.redirect = ( ".*" => "http://blog.forret.com")
}
Related posts:
- My 10 essential Wordpress plugins Since I’ve been doing quite a lot of Wordpress...
- Migration to Wordpress: me vs Murphy Some of you might have noticed my recent domain dance:...
- WP-Cache speeds up your Wordpress! Ever wondered if you needed a caching plugin for your...
- Migrating from Blogger to Wordpress 2.0 Ever since I saw the new ‘import from Blogger’ functionality...
- Create your own Wordpress plugin Wordpress has a really nifty system for adding functionality:...




thanks man!
Hey, was just curious, what version of Lighty are you running and have you had any other problems? I’ve tried a ton of rewrite rules and nothing seems to completely work with wordpress. I’m trying to migrate my blog to lighttpd 1.5 with Wordpress 2.1 and running into a slew of problems, any javascript included in wordpress plugins with a version number attached returns a 404, some of my rewritten category links return an Octet stream instead of the page. I’m at a loss and about to give up on lighty. I tried your rules and my site doesn’t work at all, this is the closes I’ve come:
url.rewrite-once = (
“^/(wp-admin|images|wp-content|awstats)/{0,1}(?!no.css)(.*)” => “$0″,
“^/.*\.(php|css|html|htm|pdf|png|gif|jpe?g|js)$” => “$0″,
“^/.*?(\?.*)?$” => “/index.php$1″
)
For those out there that are curious, this is what ended up working for me:
url.rewrite-once = (
“^/(wp-. ).*/?” => “$0″,
“^/(sitemap.xml)” => “$0″,
“^/(xmlrpc.php)” => “$0″,
“^/keyword/([A-Za-z_0-9-] )/?$” => “/index.php?keyword=$1″,
“^/.*?(?.*)?$” => “/index.php$1″
)
http://greatwebguy.com/web-servers/lighttpd/lighttpd-15-rewrite-rules-for-wordpress-22/
This is the best known solution for Permalinks in Wordpress+Lighttpd
Please check: http://sudhaker.com/web-development/wordpress/wordpress-permalinks-lighttpd.html
Cheers,
Sudhaker
@Sudhaker: I beg to differ! I’ve seen about ten different approaches to this problem so far, but http://r00tshell.com/archives/2007/05/16/wordpress-lighttpd-permalinks-without-rewrite/ is the cleverest and simplest, and it looks like it solves other problems as well. Working great for me so far. Is there some important reason to introduce a dependency on Lua?