我要投稿如果你有好的文章,欢迎分享给我们,我们会给与适当的补贴

url.rewrite for WordPress on Lighttpd

just because i need some help about let wordpress running on lighttpd. so i find this one also hoply could give you some help.

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:

  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”)
}

Add a Comment

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