It's better when it's simple

User Tools

Site Tools


URL Rewriting

By default, DokuWiki does no URL rewriting, resulting in URLs like this:

These URLs are somewhat ugly and might not be indexed well by some search engines. URL rewriting offers a solution to this, resulting in nicer URLs.

Rewriting options

DokuWiki supports two methods for URL rewriting, enabled through the userewrite option. One relies on the rewriting capabilities of the webserver; the other one handles rewritten URLs inside DokuWiki. The table below summarizes these options.

Value Info Example URL
0 No URL rewriting is used. This is the default.
1 Rewriting is handled by the webserver.
2 Rewriting is done by DokuWiki.

URL-Rewriting is disabled by default because it requires some additional configuration besides setting the appropriate config option - these configs are discussed below.

Option 1: web server

This option requires some setup in the webserver first. How to enable it, depends on the webserver used. Please refer to the linked pages below for additional info.

  • Apache – uses the mod_rewrite module. It can be enabled using a .htaccess file.
  • IIS – uses custom rewrite rules or the rewrite module
  • nginx – has built in rewriting support
  • PHP's built-in web server – needs no configuration, rewrite will work using DokuWiki's index.php router

Once the rewriting support has been enabled in the web server, this option can be enabled in the DokuWiki configuration.

Select the .htaccess option in the userewrite config dropdown. Alternatively, in your conf/local.php file, add or modify the line so it reads:

$conf['userewrite'] = 1;

In DokuWiki root folder, find the file .htaccess.dist and copy it as .htaccess. Edit it and uncomment lines referring to userwrite. It's a short file and easy to understand.

Option 2: DokuWiki

This option won't need any webserver setup. However it relies on the PATH_INFO feature of the CGI standard as implemented by Apache. Some webserver configurations might not support it.

To enable this option, select the DokuWiki internal option in the userewrite config dropdown. Alternatively, in your conf/local.php file, add or modify the line so it reads:

$conf['userewrite'] = 2;

Clean PHP session ID

Despite using “clean” URLs you may encounter a “DokuWiki” parameter in the URL looking like this:

PHP session ID:

This parameter is the PHP session ID and gets added by PHP automatically. It's completely unrelated to rewriting. To avoid it you can force PHP to always use cookies for sessions by setting the session.use_only_cookies option for PHP.

This is usually done in the php.ini config file:


You can also try:


See Also

rewrite.txt · Last modified: 2023-12-06 01:42 by nerun

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki