[dokuwiki] URL rewriting: page prefix?

  • From: Tanguy Ortolo <tanguy+dokuwiki@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 16 May 2011 13:01:58 +0200

Hello,

Working on multisite (farming) support for the Debian package, found an
issue that may be worth considering.

Simplifying, the server-side URL rewriting option does rewrite
/anything/ to doku.php?id=/anything/, except what must not be rewritten,
that is, /lib, /doku.php and /feed.php.

There is a problem with this: collisions may appear. If someone has a
page or a namespace named lib (or even doku.php or feed.php…), it would
become impossible to access it. Other collisions may appear for someone
that has put some other static content or alias inside his DokuWiki
directory.

I guess the same problem was detected some time ago for MediaWiki, and
they solved it by making all the wiki pages available under a /wiki
namespace, for instance: <http://en.wikipedia.org/wiki/DokuWiki>.

I think doing the same would solve this collision problem and greatly
simplify the rewrite rules: no more “rewrite anything, except this” or
“rewrite anything, except stuff that matches an existing static file”,
but instead only “rewrite anything starting with /wiki”.
    RewriteBase /dokuwiki
    RewriteRule ^_media/(.*)           lib/exe/fetch.php?media=$1 [PT,QSA,L]
    RewriteRule ^_detail/(.*)          lib/exe/detail.php?media=$1 [PT,QSA,L]
    RewriteRule ^_export/([^/]+)/(.*)  doku.php?do=export_$1&id=$2 [PT,QSA,L]
    RewriteRule ^wiki/(.*)             doku.php?id=$1  [QSA,L]
    RewriteRule ^$                     doku.php  [L]

I tried to test this on a test installation of DokuWiki: pages become
available at something like /dokuwiki/wiki/page, but internal links are
still generated without the prefix, like /dokuwiki/otherpage. Would it
be possible to allow this kind of rewriting, for instance by setting
    $userewrite="wiki";
or perhaps
    $userewrite=1;
    $pagesprefix="wiki";
where "wiki" may be replaced by another prefix to the user's choice (I
personally prefer "pages")?

-- 
 ,--.
: /` )   Tanguy Ortolo <xmpp:tanguy@xxxxxxxxx> <irc://irc.oftc.net/Elessar>
| `-'    Debian Maintainer
 \_

Other related posts: