How to setup lighttpd.conf to rewrite wordpress urls the right way

Posted in howto

I’ve seen many ways to solve wordpress url rewriting for lighttpd. Some people say all you need a server.error-handler-404 = “/index.php” and you’re done, but that didn’t work for me. If you’re trying to run several sites using multiple domain names with multiple installation directories, here’s how I got it to work. But take this with a grain of salt because your mileage may vary. /cliches

First make sure you include the broken-scriptfilename line in your fastcgi line. That was key to getting skins working for me.

fastcgi.server = ( ".php" =>
                     ( "localhost" =>
                       (
                         "socket" => "/var/run/lighttpd/php-fastcgi.socket",
                         "bin-path" => "/usr/bin/php-cgi",
                         "broken-scriptfilename" => "enable"
                       )
                     )
                  )

Include this once in /etc/lighttpd.conf

server.error-handler-404 = "/index.php"

Include this section once for each installation of wordpress you want to run.

$HTTP["host"] =~ "blog.rootninja.com" {
  server.document-root = "/var/www/lighttpd/wordpress1/"
  var.wpdir = "/var/www/lighttpd/wordpress1"
}

Include this section just once, and make it last, or at least put it after all the sections above.

url.rewrite-once = (
    "^" + wpdir + "(wp-.+).*/?" => "$0",
    "^" + wpdir + "/(.*.php)" => "$0",
    "^" + wpdir + "/(sitemap.xml)" => "$0",
    "^" + wpdir + "/(.*)$" => "/index.php/$1",
    "^" + wpdir + "keyword/([A-Za-z_0-9-])/?$" => wpdir + "index.php?keyword=$1"
)
Posted by admica   @   2 August 2009

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

Previous Post
« Serial driver compatibility with Unknown chipsets
Next Post
Using PHP’s explode to split a full path into directory and file name »
Powered by Wordpress   |   Lunated designed by ZenVerse