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|slimstat)(/|$) 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 ^/app/webroot/ Skip 2
    Match ^/app/(.*) Rewrite /$1 Continue
    Match ^/(.*) Rewrite /app/webroot/$1 Continue
    RequestURI exists Return
    Match (.*)\?(.*) Rewrite $1&$2 Continue
    Match ^/app/webroot/(.*) Rewrite /app/webroot/index.php?url=$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
}

Concrete5

Use the following configuration for your Concrete5 websites:

UrlToolkit {
    ToolkitID = concrete5
    RequestURI exists Return
    Match ^/index.php Return
    Match ^/(.*)\?(.*) Rewrite /index.php/$1&$2
    Match ^/(.*) Rewrite /index.php/$1
}

DokuWiki

Use the following configuration for your DokuWiki websites:

UrlToolkit {
    ToolkitID = dokuwiki
    Match ^/(bin|conf|data|inc)/ DenyAccess
    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
    Match ^/$ Rewrite /doku.php
    RequestURI exists 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 = drupal7
    RequestURI isfile Return
    Match /favicon.ico Return
    Match .* Rewrite /index.php
}

UrlToolkit {
    ToolkitID = drupal6
    RequestURI exists Return
    Match ^/favicon.ico$ Return
    Match /(.*)\?(.*) Rewrite /index.php?q=$1&$2
    Match /(.*) Rewrite /index.php?q=$1
}

Habari

Use the following configuration for your Habari websites:

UrlToolkit {
    ToolkitID = habari
    Match ^/(system/(classes|locale|schema|$)) Rewrite /index.php
    RequestURI exists Return
    Match .*\?(.*) Rewrite /index.php?$1
    Match .* Rewrite /index.php
}

jCore

Use the following configuration for your jCore websites:

UrlToolkit {
    ToolkitID = jcore
    RequestURI exists Return
    Match /(.*)\?(.*) Rewrite /index.php?path=$1&$2
    Match /(.*) Rewrite /index.php?path=$1
}

Joomla!

Use the following configuration for your Joomla! websites:

UrlToolkit {
    ToolkitID = joomla
    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 /index.php Return
    Match ^/component/ Skip 2
    Match ^(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ Skip 1
    Skip 1
    Match .* Rewrite /index.php
}

Kohana

Use the following configuration for your Kohana websites:

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

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.

MODx

Use the following configuration for your MODx websites:

UrlToolkit {
    ToolkitID = modx
    RequestURI exists Return
    Match ^/(.*)$ Rewrite /index.php?q=$1
}

ownCloud

Use the following configuration for your ownCloud websites:

UrlToolkit {
    ToolkitID = owncloud
    Match ^/data DenyAccess
}

VirtualHost {
    ...
    WebDAVapp = yes
    AllowDotFiles = yes
    UseToolkit = owncloud
}

phpSQLiteCMS

Use the following configuration for your phpSQLiteCMS websites:

UrlToolkit {
    ToolkitID = phpsqlitecms
    RequestURI exists Return
    Match ^/(.*) Rewrite /index.php?qs=$1
}

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
}

Symphony

Use the following configuration for your Symphony websites:

UrlToolkit {
  ToolkitID = symphony
  Match ^/manifest/.* DenyAccess
  Match ^/workspace/utilities/.*\.xsl$ DenyAccess
  Match ^/workspace/pages/.*\.xsl$ DenyAccess
  Match ^/.*\.sql$ DenyAccess
  Match ^/favicon.ico$ Return
  Match ^/symphony\/api(\/(.*\/?))?\?(.*)$ Rewrite /extensions/rest_api/handler.php?url=$1&$3
  Match ^/symphony\/api(\/(.*\/?))?$ Rewrite /extensions/rest_api/handler.php?url=$1
  Match ^/symphony\/api Exit
  Match ^/image\/(.+\.(jpg|gif|jpeg|png|bmp))$ Rewrite /extensions/jit_image_manipulation/lib/image.php?param=$1
  Match ^/symphony\/?$ Rewrite /index.php?mode=administration
  RequestURI exists Return
  Match (.*)\?(.*) Rewrite $1&$2 Continue
  Match ^/symphony(\/(.*\/?))?$ Rewrite /index.php?symphony-page=$1&mode=administration
  Match ^/(.*\/?)$ Rewrite /index.php?symphony-page=$1
}

TYPO3

Use the following configuration for your TYPO3 websites:

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

WolfCMS

Use the following configuration for your WolfCMS websites:

UrlToolkit {
    ToolkitID = wolfcms
    Match ^/site/install/index.html$ Rewrite /site/install/index.php?rewrite=1
    Match ^/site/install/index.php$ Rewrite /site/install/index.php?rewrite=1
    Match ^/site/install/$ Rewrite /site/install/index.php?rewrite=1
    RequestURI exists Return
    Match ^/site/admin(.*)$ Rewrite /site/admin/index.php?$1
    Match ^/site(.*)$ Rewrite /site/index.php?WOLFPAGE=$1
}

The 3 match rules above RequestURI are for clean URL installation. They should be removed after installation.

WordPress

Use the following configuration for your WordPress websites:

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

Yii

Use the following configuration for your Yii websites:

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

Zend

Use the following configuration for your Zend websites:

UrlToolkit {
    ToolkitID = zend
    Match ^/.*\.(js|ico|gif|jpg|jpeg|png|css|svg)(/|$) Return
    Match .* Rewrite /index.php
}

VirtualHost {
    ...
    WebsiteRoot = /path/to/website/public
    UseToolkit = zend

    # Required so that Zend can find the application root directory
    Setenv APPLICATION_PATH = /path/to/website
    # Optional, for more verbose error messsages
    Setenv APPLICATION_ENV = development
}