url.rewrite for Wordpress on Lighttpd

LightyThis 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:

  1. 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"
    )
    }
  2. 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")
}

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • TailRank

If you're new here, you may want to subscribe to my RSS feed or receive updates via email. Thanks for visiting!

9 Responses to “url.rewrite for Wordpress on Lighttpd”


  1. Gravatar Icon 1 wu

    thanks man!

  2. Gravatar Icon 2 webguy

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

  3. Gravatar Icon 3 webguy

    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/

  1. 1 tin_the_fatty weblog » Blog Archive » WordPress Migrated to Run on Lighttpd+FastCGI/PHP5
  2. 2 Lighttpd dan ModRewrite | WordPress [at] mimpikami . com
  3. 3 Terbaik.Net » Blog Archive » Lighttpd dan ModRewrite
  4. 4 the real kucrut
  5. 5 Dennis 的無差別 Blog» Blog Archive - » Wordpress URL REWRITE on LIGHTTPD
  6. 6 Lighttpd ModRewrite pour Drupal, Wordpress, Dotclear et Zenphoto | bonvga.net

Leave a Reply