Project

General

Profile

DokuWiki CleanURLs with Lighttpd

Here is a version from darix in irc.freenode.net #lighttpd which fixed many errors such as optional trailing slash etc.


#!lighttpdconf
$HTTP["host"] =~ "some.otherhost.com" {
    server.document-root = "/var/www/htdocs" 
    # DO NOT FORGET THE TRAILING SLASH HERE
    # var.wiki_base = "/wiki/" 
    # var.wiki_base = "/" 
    var.wiki_base = "/" 
    #
    $HTTP["url"] =~ "^" + var.wiki_base {
      #RewriteRule ^$          doku.php  [L]
      #RewriteRule ^index.php$ doku.php
      index-file.names = ("doku.php")
    }
    url.rewrite = (
      #
      "^" + var.wiki_base + "lib/.*$" => "$0",
      #RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]
      #RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L]
      #RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]
      #RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
      #RewriteRule ^index.php$               doku.php
      "^" + var.wiki_base + "_media/(.*)"          => var.wiki_base + "lib/exe/fetch.php?media=$1",  #  [QSA,L]
      "^" + var.wiki_base + "_detail/(.*)"         => var.wiki_base + "lib/exe/detail.php?media=$1", #  [QSA,L]
      "^" + var.wiki_base + "_detail/(.*)\?id(.*)"         => var.wiki_base + "lib/exe/detail.php?media=$1&id=$2", #  [QSA,L]
      "^" + var.wiki_base + "_export/([^/]+)/(.*)" => var.wiki_base + "doku.php?do=export_$1&id=$2", #  [QSA,L]
      "^" + var.wiki_base + "doku.php.*"           => "$0",
      "^" + var.wiki_base + "index.php/(.*)"           => var.wiki_base + "doku.php?id=$1",
      "^" + var.wiki_base + "index.php\?display=(.*)"           => var.wiki_base + "doku.php?id=$1",
      "^" + var.wiki_base + "index.php.*"           => "$0",
      "^" + var.wiki_base + "feed.php.*"           => "$0",
      "^" + var.wiki_base + "sitemap.xml.gz"           => "$0",
      "^" + var.wiki_base + "(.*)\?(.*)"           => var.wiki_base + "doku.php?id=$1&$2",           #  [QSA,L]
      "^" + var.wiki_base + "(.*)"                 => var.wiki_base + "doku.php?id=$1",              #  [QSA,L]
    )
}

DokuWiki Config

To the local.php or local.protected.php, add


$conf['userewrite'] = '1';

Some things are maybe missing (i had some problems with the detail.php) but the basic setup works (for me).

Updated by Terminar over 5 years ago · 3 revisions