DokuWiki, IIS, and mod_rewrite

I finally got DokuWiki working on an IIS installation with friendly URL’s. Apache’s mod_rewrite doesn’t exist for IIS, but a similar module called URL Rewrite for IIS works nearly as well.

It took a fair amount of trial and error (and the useful regex tester from the makers of ISAPI rewrite). Here are the steps I used to get it working.

  1. Download & install mod_rewrite for IIS following their instructions.
  2. Use the mod_rewrite.ini sample below, and configure it for your own particular server. Note that this module does not use .htaccess files like mod_rewrite does. It only accepts regex commands in the mod_rewrite.ini file instead.
  3. Set userewrite and useslash to 1 in DokuWiki’s /conf/local.php file.

Hope this helps some people out!

Debug 0
Reload 10000
# Browse LOT

# The following is just a test I used to see if mod_rewrite was working
# RewriteRule ^/(help.php) /mod_rewrite.htm 

# Replace <pre> with the prefix to your DokuWiki install, if it is not in the root

RewriteRule ^/<pre>/_media/(.*)\?(.*) /intranet/docs/lib/exe/fetch.php?media=$1&$2 [l]
RewriteRule ^/<pre>/_detail/(.*)\?(.*) /intranet/docs/lib/exe/detail.php?media=$1&$2 [l]
RewriteRule ^/<pre>/_detail/(.*) /intranet/docs/lib/exe/detail.php?media=$1 [l]
RewriteRule ^/<pre>/$ /intranet/docs/doku.php [l]

RewriteRule ^/<pre>/lib/(.*) /intranet/docs/lib/$1 [l]
RewriteRule ^/<pre>/(.*)\?do=(.*) /intranet/docs/doku.php?id=$1&do=$2 [l]
RewriteRule ^/<pre>/doku.php\?id=(.*) /intranet/docs/doku.php?id=$1 [l]
RewriteRule ^/<pre>/(.*) /intranet/docs/doku.php?id=$1 [l]

3 Comments on “DokuWiki, IIS, and mod_rewrite”

Lyndsay, May 10th, 2007 at 6:46 am

Thanks for a couple of great articles on dokuwiki - they were a huge help in setting my own site.

FYI, I added a RewriteRule to handle namespace indexes:

RewriteRule ^/(.)?idx=(.) /doku.php?idx=$2 [L]

Also, this plugin provides an even better index:
http://wiki.splitbrain.org/plugin:indexmenu

xyz, June 8th, 2007 at 6:00 am

IIS Mod-Rewrite ( http://www.micronovae.com/ModRewrite/ModRewrite.html ) is fully compatible with Apache mod_rewrite, and also it’s Pro version supports .htaccess.

I tried it with Wordpress and worked perfectly, as if I used it with Apache. I only had to add the following line at the beginning of “wp-settings.php”:

$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];

I’m not sure how it works with DokuWiki, but it’s worth trying it.

jamesvl, June 13th, 2007 at 3:58 pm

Thanks for the tip on IIS Mod-Rewrite - I’ll check it out and see how it works for us.

Note for others: It is a commercial production though; but I suppose if you’re running an IIS server you’re already in the realm of non-open source software and having to pay for licenses.

James, July 17th, 2007 at 2:56 pm

I tried IIS mod-rewrite with Dokuwiki and the clean permalinks with .htaccess worked perfect. No need to change anything in the code.

Thanks XYZ

DJ, August 2nd, 2007 at 8:43 am

http://www.iismods.com is not up&running anymore.