DokuWiki URL rewriting in LightTPD

I’ve finally decided to setup DokuWiki as a personnal wiki, as it handles 2 of my first needs: namespaces and ACLs by namespaces.

Here are the options you need to set up to get clean URL rewriting in LightTPD.

In conf/dokuwiki.conf:

 $conf['userewrite']  = 1;        //this makes nice URLs: 0: off 1: .htaccess 2: internal  $conf['useslash']    = 1;        //use slash instead of colon? only when rewrite is on

The second line is optional, but I feel better handling namespaces pages with / - as subdirectories - instead of colons.

Actually, you can set option 2 (internal) for the userewrite parameter. Yet, URLs would be like "wiki/doku.php/mypage", and I’d prefer something like "wiki/mypage". In such a case (option 1), you need to set the following rules in lighttpd.conf:

 "^/wiki/?$" => "/wiki/doku.php",  "^/wiki/lib/(.*)/?$" => "/wiki/lib/$1",  "^/wiki/(.*)\?do=(.*)/?$" => "/wiki/doku.php?id=$1&do=$2",  "^/wiki/(.*)/?$" => "/wiki/doku.php?id=$1\

Comments

3 Responses to “DokuWiki URL rewriting in LightTPD”

  1. Gordon on May 24th, 2006 10:17 pm

    I’m following your instructions but there seems to be one small issue with attempting to access the base directory of the wiki with a trailing /. As an example, http://www.wavekave.org/recipes will work fine and all of the sub-articles work as well, however http://www.wavekave.org/recipes/ does not work and tries to download the site, rather than parse the php.

    I am running lighttpd, php5 and the latest dokuwiki. If you could shed any light on this for me it would be great. Perhaps more of your lighttpd.conf file would help? Thanks in advance.

  2. Timon on June 8th, 2006 4:19 pm

    Didn’t work for me with media files. Instead I’d suggest using the following regex:

             url.rewrite = ( "^/?$" => "/doku.php",                "^/lib/(.*)/?$" => "/lib/$1",                "^/_media/(.*)?\?(.*)$" => "/lib/exe/fetch.php?media=$1&$2",                "^/_detail/(.*)?\?(.*)$" => "/lib/exe/detail.php?media=$1&$2",                "^/(.*)\?do=(.*)/?$" => "/doku.php?id=$1&do=$2",                "^/(.*)/?$" => "/doku.php?id=$1",              )
  3. brcha on June 19th, 2007 6:27 pm

    Timon’s rules rule for me. Thanx :)

Leave a Reply

You must be logged in to post a comment.