MediaWiki:Rewrite Rules

From ThinkLemon

Jump to: navigation, search

The MediaWiki installation here at ThinkLemon is placed in the /wiki directory. To make URL rewriting possible, for this directory, the following rewrite rules are used.

# BEGIN Wiki
# Don't rewrite requests for files in MediaWiki subdirectories,
# MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt
RewriteCond %{REQUEST_URI} !^/wiki/stylesheets/
RewriteCond %{REQUEST_URI} !^/wiki/skins/
RewriteCond %{REQUEST_URI} !^/wiki/(redirect|texvc|index).php
RewriteCond %{REQUEST_URI} !^/wiki/sitemap.xml.php
RewriteCond %{REQUEST_URI} !^/wiki/error/(40(1|3|4)|500).html
RewriteCond %{REQUEST_URI} !^/wiki/favicon.ico
RewriteCond %{REQUEST_URI} !^/wiki/robots.txt

# Make sure there is no query string (Unless user is making a search)
RewriteCond %{QUERY_STRING} ^$ [OR] %{REQUEST_URI} ^/wiki/Special:Search

# Rewrite http://wiki.domain.tld/article properly, this is the main rule
RewriteRule ^wiki/?(.*)$ /wiki/index.php?title=$1 [L,QSA]
# END Wiki

Notes:

  1. These rules were found at http://meta.wikimedia.org/wiki/Rewrite_rules and adapted for the situation over here at ThinkLemon.com.
  2. ThinkLemon uses MediaWiki 1.5.x placed in the /wiki directory.
  3. You need to have mod_rewrite enabled in apache.
Personal tools
related