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.

[code lang=”ini”]
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]wordpress, permalinks, lighttpd, lighty, rewrite[/tags]

4 thoughts on “WordPress permalinks with lighttpd (lighty)

  1. Pingback: Schöne Wordpress Permalinks mit Lighttpd Webserver | Chris im Netz - Software, Hardware, Tutorials und mehr..

Comments are closed.