Mod Rewrite

Also available in Deutsch

Basics

This is a module for the Apache webserver (v1.x and v2.x) and rewrites requested URLs on the fly. It operates both in per-server context (Apache v1.x: httpd.conf, Apache v2.x: apache2.conf) and per-directory context (.htaccess). Detailed informations can be found on the Apache Module Homepage.


So what does it to WackoWiki?!
1. mod_rewrite enabled: http://www.example.com/Download
2. mod_rewrite disabled: http://www.example.com/index.php?page=Download
That's it ;-)


Howto enable mod_rewrite

Of course, you need an Apache webserver WackoWiki is running on, and the module mod_rewrite has to be installed and activated.

.htaccess

If you have no privileges to edit the apache2.conf (e.g. you rent webspace) or simply you don't want to, you have to use the .htaccess-method (don't forget the dot!) with the following content:

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond    %{REQUEST_FILENAME}  -d
 RewriteRule ^(.*/[^\./]*[^/])$ $1/
 RewriteRule ^(robots\.txt)$ robots.txt [L]
 RewriteRule ^(sitemap\.xml)$ sitemap.xml [L]
 RewriteRule ^(favicon\.ico)$ favicon.ico [L]
 RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
</IfModule>

This file is shipped with the WackoWiki package you downloaded, you find this file inside the Wacko folder. If you can't find it, just create it (Permission: -rwxr-xr-x).


For Admins:
Make sure that your .htaccess files are not ignored: in your apache configuration file (http.conf or apache2.conf), make sure that for the directory where the wiki is:

AllowOverride None

is not set. Because then .htaccess files are ignored.
AllowOverride All

definitely works, I don't know for other values.
CarlDevos /24.02.2005 17:26/


httpd.conf / apache2.conf

If you want to edit the httpd.conf / apache2.conf file directly, please make sure to delete or rename the .htaccess in your Wacko folder.
Now add the following lines to your configuration file:

#Wacko URL-rewriting

    Options Indexes Includes FollowSymLinks MultiViews
    AllowOverride All
    RewriteEngine on
    RewriteRule ^(index.php?.*)$ - [S=1]
    RewriteRule ^(.*)$ /wacko/index.php?page=$1 [QSA,PT,L]
    Order allow,deny
    Allow from all

Restart your webserver to enable the modifications!

Special cases

special .htaccess files

RewriteBase

If your webserver's URLs are not directly related to physical file paths, you will need to use RewriteBase in every .htaccess file where you want to use RewriteRule directives.

RewriteBase /

RewriteBase /folder/


e.g. .htaccess

<IfModule mod_rewrite.c>
 RewriteEngine on
 
 RewriteBase /doc/
 
 RewriteCond    %{REQUEST_FILENAME}  -d
 RewriteRule ^(.*/[^\./]*[^/])$ $1/
 RewriteRule ^admin\.php$ admin.php [L]
 RewriteRule ^(robots\.txt)$ robots.txt [L]
 RewriteRule ^(sitemap\.xml)$ sitemap.xml [L]
 RewriteRule ^(favicon\.ico)$ favicon.ico [L]
 RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]

</IfModule>


related

  1. http://httpd.apache.org/docs/c[..]ite.html#rewritebase
  2. https://wackowiki.sourceforge.[..].php?id=397#bugnotes

Referring pages:

Doc/Deutsch/RewriteModus