Use of URL rewriting (mod_rewrite) to generate cleaner site URL's

Created by: spiderr, Last modification: 30 Jun 2008 (09:17 UTC) by Kozuch
PrettyUrls use the Apache webserver's mod_rewrite module to handle URL rewriting to convert browser references such as
to web server references such as

So far Blogs, Wiki, Fisheye and Users have had code added to handle the feature:

Where to find it

Look for PrettyUrls in Admin -> Kernel -> Features

NB: If mod_rewrite is not activated, activating this feature will generally disable all the links in left and right hand columns.

About mod_rewrite

mod_rewrite comes as part of apache by default and has to be enabled in your httpd.conf file:

<Directory />
    Options FollowSymLinks
    AllowOverride None

goes to

<Directory />
    Options FollowSymLinks
    AllowOverride FileInfo

this should be done for the / dir and your html dir such as /var/www/

First note

Depending on your web server configuration, the default supplied .htaccess files may not work. One thing to try is to comment out the "RewriteBase" line in the file. For example:

       RewriteBase     /wiki/

goes to

#       RewriteBase     /wiki/

Second note

There can be issues with mod_rewrite in apache when your pretty url partially matches a filename that already phisycally exists in the same directory and Option MultiViews is turned on. For example in Treasury package:

RewriteRule    ^download/([0-9]+)?(\&.*)?$  download.php?content_id=$1$2  [L,QSA]

Apache searches for a file download and it partially matches download.php. Option MultiViews allows apache to reach download.php literally as download.php but also as download. It happends before RewriteRule is applied, so in fact your request goes do download.php but because of MultiViews, not mod_rewrite and therefore with no arguments.

To solve this you have to turn off Option MutliViews in your apache configuration or in this directory in your .htaccess file:

Option -MutliViews
RewriteRule    ^download/([0-9]+)?(\&.*)?$  download.php?content_id=$1$2  [L,QSA]

Information about apache's MultiViews can be found on and some blog posts that explain it are on and

See Also:


Very important feature.

by mlpvolt, 29 Mar 2006 (23:58 UTC)
As much as possible, it would be great to ensure that one can go to a page directly with

or better yet page name (soft spaces)

I've had people tell me this can be done. Never seen it in action though.

A toggle that makes one feature "primary" such that if you are using mostly blogs then

works, but a wiki page in the same site would require

perhaps this can be incorporated in PrettyUrlsExtended.

  Page 1 of 1  1