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.
- Download & install mod_rewrite for IIS following their instructions.
- Use the
mod_rewrite.inisample below, and configure it for your own particular server. Note that this module does not use.htaccessfiles like mod_rewrite does. It only accepts regex commands in themod_rewrite.inifile instead. - Set
userewriteanduseslashto1in DokuWiki’s/conf/local.phpfile.
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]
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
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.
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.
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
http://www.iismods.com is not up&running anymore.