I have been moving some of my sites around and the turn came to my blog. Since I have decided to try
lighttpd on my new server I was wondering how easy would it be to setup
Serendipity on it.
Well the basic install went pretty smoothly, but I wanted, of course, to use "friendly" URLs. For that Serendipity supplies .htaccess file with Apache mod_rewrite rules. With a little bit of effort it was possible for me to convert those into rewrite rules that lighttpd would understand:
# Serendipidy rewrites
url.rewrite-once = (
"(archives/([0-9]+)-[0-9a-zA-Z\._!;,\+\-]+\.html)" => "index.php?/$1",
"(authors/([0-9]+)-[0-9a-zA-Z\._!;,\+\-]+)" => "index.php?/$1",
"(feeds/categories/([0-9;]+)-[0-9a-zA-Z\._!;,\+\-]+\.rss)" => "index.php?/$1",
"(feeds/authors/([0-9]+)-[0-9a-zA-Z\._!;,\+\-]+\.rss)" => "index.php?/$1",
"(categories/([0-9;]+)-[0-9a-zA-Z\._!;,\+\-]+)" => "index.php?/$1",
"archives/([/A-Za-z0-9-]+)\.html" => "index.php?url=/archives/$1.html",
"([0-9]+)[\-][0-9a-zA-Z\-]*\.html" => "index.php?url=$1-article.html",
"feeds/(.*)" => "index.php?url=/feeds/$1",
"unsubscribe/(.*)/([0-9]+)" => "index.php?url=/unsubscribe/$1/$2",
"approve/(.*)/(.*)/([0-9]+)" => "index.php?url=approve/$1/$2/$3",
"delete/(.*)/(.*)/([0-9]+)" => "index.php?url=delete/$1/$2/$3",
"(admin|entries)/(.+)?" => "index.php?url=$1/$2",
"admin$" => "index.php?url=/admin",
"archive/?" => "index.php?url=/archive",
"(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)" => "rss.php?file=$1&ext=$2",
"(plugin|plugin)/(.*)" => "index.php?url=$1/$2",
"search/(.*)" => "index.php?url=/search/$1",
"(serendipity\.css|serendipity_admin\.css)" => "index.php?url=/$1",
"index\.(html?|php.+)" => "index.php?url=index.html",
"htmlarea/(.*)" => "htmlarea/$1",
"(.*\.html?)" => "index.php?url=/$1"
)
We only need to prevent some files from being sent to the user:
url.access-deny = ( ".tpl.php", ".tpl", ".sql", ".inc.php")
I guess the future will show how many security holes I have opened playing with these regexs