Quantcast

WordPress permalinks with lighttpd (lighty)

WordPress out of the box works just fine with lighttpd. But you will run into issues if you want nice looking and search engine friendly URLs. To get that you need to turn on the non-default permalinks. Most of the information out there on how to set your webserver up to handle this is written for apache so if you are using lighttpd it is a little harder to find the correct way of doing the URL re-writing.

For more information about why you should use custom permalinks look here or here.

I started with this post but it seemed to lack a few rules so I went looking again. Next I found this post that has a better set of rules. Between these two I came up with a set of my own that includes some extra rules for some plugins.

url.rewrite = (
"^/(wp-admin|images|wp-content|awstats)/{0,1}(?!no.css)(.*)" => "$0",
"^/sitemap/?$" => "/index.php?pagename=sitemap&pg=1",
"^/sitemap/([0-9]+)/?$" => "/index.php?pagename=sitemap&pg=$1",
"^/library/?$" => "/index.php?now_reading_library=true",
"^/library/tag/(.+)/?$" => "/index.php?now_reading_tag=true&now_reading_tag=$1",
"^/library/([0-9]+)/?$" => "/index.php?now_reading_single=true&now_reading_id=$1",
"^/page/([0-9]+)/?$" => "/index.php?paged=$1",
"^/date/([0-9]+)/?([0-9]+)/?$" => "/index.php?m=$1$2",
"^/date/([0-9]+)/?([0-9]+)/?([0-9]+)?$" => "/index.php?m=$1$2$3",
"^/feed/(feed|rdf|rss|rss2|atom)/?$" => "/index.php?feed=$2",
"^/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$" => "/index.php?category_name=$1&feed=$2",
"^/(.+)/(feed|rdf|rss|rss2|atom)/?$" => "/index.php?category_name=$1&feed=$2",
"^/(.+)/([0-9]+)/[^/]+/?/feed/(feed|rdf|rss|rss2|atom)/?$" => "/index.php?category_name=$1&p=$2&feed=$3",
"^/(.+)/([0-9]+)/[^/]+/?/(feed|rdf|rss|rss2|atom)/?$" => "/index.php?category_name=$1&p=$2&feed=$3",
"^/(.+)/([0-9]+)/[^/]+/?/page/?([0-9]{1,})/?$" => "/index.php?category_name=$1&p=$2&paged=$3",
"^/(.+)/([0-9]+)/[^/]+/?([0-9]+)?/?$" => "/index.php?category_name=$1&p=$2&page=$3",
"^/(.+)/([0-9]+)/[^/]+/?/trackback/?$" => "/index.php?category_name=$1&p=$2&tb=1",
"^/category/(.+)/?$" => "/index.php?category_name=$1",
"^/?$" => "/index.php",
"^/([_0-9a-zA-Z-]+)/?$" => "/index.php?page_id=$1"
)

The blog is off the root of the site so unlike the first post everything starts with just ^/ and nothing else. I am still not completely happy with the feed structure but what I have works for rss2 and that seems good enough to me. I used a custom permalink structure of: /%category%/%post_id%/%postname%/

Tags: , , , ,

This entry was posted in system administration. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. Posted September 26, 2006 at 9:57 pm | Permalink

    Thanks carson! I just ran into this.

  2. Posted March 15, 2007 at 9:32 am | Permalink

    I have a url.rewrite config in 4 lines that works!
    http://blog.forret.com/2007/03/urlrewrite-for-wordpress-on-lighttpd/

  3. Posted April 24, 2010 at 10:28 am | Permalink

    My config keeps your lighttpd.conf clean in case of multiple wordpress hosted on one server: http://www.chrische.de/2010/04/lighttpd-in-verbindung-mit-wordpress-und-rewrites/

One Trackback

  1. [...] Wenn es noch nicht auf Anhieb klappt auch an solche Sachen denken wie "Cache leeren" (via) Verwandte Artikel:AppServ – Kompletter Webserver für Windows Author: chris [...]

Post a Comment

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

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>