Use Pretty Permalinks on Lighttpd

 Well on the WordPress site they said the Pretty Permalinks like
/category/title is only available on Apache. Well this is definitely
not true as long as you know your web server.

Here is how I made it with Lighttpd, and some tips to keep my original
rss link.

My original rss link is http://dryice.name/blog/index.rss. The new rss
link is http://dryice.name/blog/rss/. And I can use the “almost
pretty” link like /index.php/%category%/

Here’s what I do. I’ll use /blog instead of /wordpress as the root of
my blog to keep consisten with my original Pyblosxom URL.

  1. In the admin page, options->general. Make sure “WordPress address”
    and “blog address” are http://dryice.name/blog

  2. In options->permalinks, select “custome, specify below” and fill in:

    /%category%/%postname%/

and then update.

  1. In the lighttpd.conf file, add:

    url.rewrite-once = (
    "^/blog/((?!(sitemap.xml|wp-)).*)$" => "/blog/index.php/$1",
    )

This line tells lighttpd to rewriete any URLs under /blog but not
sitemap.xml and not started with wp- to be write to
/blog/index.php/.., which will show the correct article, search
result, tag, etc.

If you don’t have a previous blog, then you are all done. Restart
lighttpd and it should work.

  1. If you need to keep some previous link like me, change the rewrite
    rule like this:

    url.rewrite-once = (
    "^/blog/((?!(sitemap.xml|index.rss|wp-)).*)$" => "/blog/index.php/$1",
    )

    and add a re-direct rule:

    url.redirect = (
    "^/blog/index.rss"  => "/blog/rss",
    )

    We need to update the rewrite because in Lighttpd, re-write happens
    BEFORE re-direct. So we have to prevent the re-write of
    /blog/index.rss there.

Update(Sep 4, 2007) Some RSS readers won’t follow 301 redirect, for example, Google Reader (as of this writing). Please read my another post about this.

Tags: , , , ,

Post a Comment

You could use <code type="name"> to get your code colorized

Your email is never published nor shared. Required fields are marked *

Close
E-mail It