User Tools

Site Tools


Setting up URL Rewrite on shared windows Plesk hosting

Setting up URL rewriting for Dokuwiki is a little bit of a challenge under shared Windows Hosting. Much easier under Linux hosting as the use of .htaccess is pretty straight forward.

Under Windows, you need to use web.config and is often doubtful if you have everything you need on your hosting provider to make this happen. This article will help you get the most commonly desire URL format working.


Firstly, the guide to general URL rewrite for dokuwiki is here. It's good to have a read over to be familiar with the concept and how much dokuwiki can support it out of the box.

The format

By default, this is the format of URL used in a default installation:

What the average user really wants is:

Tastes vary, of course, but this is what this article will be shooting for.

URL Rewriting on Windows

This will be done using a web.config. You will need the following formatted file:

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^([^/]+)/?$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <action type="Rewrite" url="doku.php?id={R:1}" />

Create a web.config file and paste the above into it. Upload the file to your blog/ folder.

You might have to restart your website. But once you do, try the following url format to test:

If this gives you a 404 error, the URL rewrite has not worked. Firstly check your hosting features to see if URL Rewrite is supported. If you see nothing, open a ticket to ask. They might enable it for you.

The first part is done: you can access the page using the new URL format, and it will display. But if you see that new links to other pages still renders in the old format, you need to enable 'Nice URLs'.

  1. Log into the Admin area of Dokuwiki
  2. Go to Configuration Manager
  3. Find the Use nice URLs settings and change it .htaccess

Yes I know, this is not the settings for Windows IIS, but it will work for us in the link rewriting.

Ensure that the .htaccess in the same root folder is:

## You should disable Indexes and MultiViews either here or in the
## global config. Symlinks maybe needed for URL rewriting.
#Options -Indexes -MultiViews +FollowSymLinks
## make sure nobody gets the htaccess, README, COPYING or VERSION files
<Files ~ "^([\._]ht|README$|VERSION$|COPYING$)">
    <IfModule mod_authz_core.c>
        Require all denied
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
## Don't allow access to git directories
<IfModule alias_module>
    RedirectMatch 404 /\.git
## Uncomment these rules if you want to have nice URLs using
## $conf['userewrite'] = 1 - not needed for rewrite mode 2
RewriteEngine on
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  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php
## Not all installations will require the following line.  If you do,
## change "/dokuwiki" to the path to your dokuwiki directory relative
## to your document root.
#RewriteBase /dokuwiki
## If you enable DokuWikis XML-RPC interface, you should consider to
## restrict access to it over HTTPS only! Uncomment the following two
## rules if your server setup allows HTTPS.
#RewriteCond %{HTTPS} !=on
#RewriteRule ^lib/exe/xmlrpc.php$      https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

In our example above, you may need to ensure the line:

RewriteBase /dokuwiki


RewriteBase /blog

if you need it. This is to suit the example site for this article.


Now you should be able to visit pages using the new nicer URL format, and in addition all links will display the nicer new format.

Old links can still be used which keeps compatibility with external links to your site.

dokuwiki_url_rewrite_windows_plesk.txt ยท Last modified: 2021/02/02 01:24 (external edit)