Hiawatha
A secure and advanced webserver

HOWTO: URL rewrite rules

This page contains URL rewrite rules for some Content Management Systems, wiki's, webmail and other webprograms.

Banshee

Use the following configuration for your Banshee websites:

UrlToolkit {
    ToolkitID = banshee
    RequestURI isfile Return
    Match ^/(css|files|images|js)/ Return
    Match ^/(favicon.ico|robots.txt|sitemap.xml)$ Return
    Match .*\?(.*) Rewrite /index.php?$1
    Match .* Rewrite /index.php
}

CakePHP

Use the following configuration for your CakePHP websites:

UrlToolkit {
    ToolkitID = cakephp
    Match /(.*) Rewrite /app/webroot/$1
}

CodeIgniter

Use the following configuration for your CodeIgniter websites:

UrlToolkit {
    ToolkitID = codeigniter
    RequestURI exists Return
    Match ^/(index\.php|images|robots\.txt) Return
    Match .* Rewrite /index.php
}

DocuWiki

Use the following configuration for your DokuWiki websites:

UrlToolkit {
    ToolkitID = dokuwiki
    Match ^/(bin|conf|inc)/ Skip 1
    Match ^/_media/(.*)\?(.*) Rewrite /lib/exe/fetch.php?media=$1&$2
    Match ^/_media/(.*) Rewrite /lib/exe/fetch.php?media=$1
    Match ^/_detail/(.*)\?(.*) Rewrite /lib/exe/detail.php?media=$1&$2
    Match ^/_detail/(.*) Rewrite /lib/exe/detail.php?media=$1
    Match ^/_export/([^/]+)/(.*) Rewrite /doku.php?do=export_$1&id=$2
    RequestURI isfile Return
    Match /(.*)\?(.*) Rewrite /doku.php?id=$1&$2
    Match /(.*) Rewrite /doku.php?id=$1
}

Drupal

Use the following configuration for your Drupal websites:

UrlToolkit {
    ToolkitID = drupal
    RequestURI exists Return
    Match ^/(.*) Rewrite /index.php?q=$1
}
Because Drupal has serious performance issues, I strongly discourage the use of Drupal.

Joomla!

Use the following configuration for your Joomla! websites:

UrlToolkit {
    ToolkitID = joomla
    Match mosConfig_[a-zA-Z_]{1,21}(=|\%3D) DenyAccess
    Match base64_encode.*\(.*\) DenyAccess
    Match (<|%3C).*script.*(>|%3E) DenyAccess
    Match GLOBALS(=|\[|\%[0-9A-Z]{0,2}) DenyAccess
    Match _REQUEST(=|\[|\%[0-9A-Z]{0,2}) DenyAccess
    RequestURI exists Return
    Match .* Rewrite /index.php
}

Kohana

Use the following configuration for your Kohana websites:

UrlToolkit {
    ToolkitID = kohana
    Match ^/(application|system) DenyAccess
    RequestURI exists Return
    Match ^/(.*) Rewrite /index.php/$1
}

VirtualHost {
    ...
    TriggerOnCGIstatus = false
    EnablePathInfo = yes
    UseToolkit = kohana
}
Set $config['site_domain'] to '/' and $config['index_page'] to ''.

MediaWiki

Use the following configuration for your MediaWiki websites:

UrlToolkit {
    ToolkitID = mediawiki
    RequestURI exists Return
    Match /wiki/(.*) Rewrite /index.php?title=$1
}

VirtualHost {
    ...
    TriggerOnCGIstatus = false
    UseToolkit = mediawiki
}
Set $wgArticlePath to "/wiki/$1" in LocalSettings.php. If you often see white pages, set $wgEnableParserCache and $wgCachePages to false. Yes, this is due to a bug in MediaWiki's caching routines.

RoundCube

Use the following configuration for your RoundCube websites:

UrlToolkit {
    ToolkitID = roundcube
    Match (/.*\.inc|^_.*) DenyAccess
    Match /mail/logs/.* DenyAccess
    Match /mail/temp/.* DenyAccess
    Match /mail/config/.* DenyAccess
}

SilverStripe

Use the following configuration for your SilverStripe websites:

UrlToolkit {
    ToolkitID = silverstripe
    RequestURI isfile Return
    Match (.*)\?(.*) Rewrite $1&$2 Continue
    Match ^/(.*) Rewrite /sapphire/main.php?url=$1
}

VirtualHost {
    ...
    TriggerOnCGIstatus = no
    UseToolkit = silverstripe
}

WordPress

Use the following configuration for your WordPress websites:

UrlToolkit {
    ToolkitID = wordpress
    RequestURI exists Return
    Match .* Rewrite /index.php
}