Very short URLs with Mediawiki

August 10th, 2007

When it comes to configuring Mediawiki to have very short URLs, according to the Mediawiki documentation it seems the possibilities are endless. It you go through he page, in Austrian we would see it’s like “Kraut und RĂ¼ben”, which means something like it’s a mess, unordered, crowded.

My simple goal was: have the shortest possible article URLs, ideally http://server/Article and not http://server/dir/index.php/Article.

With a simple .htaccess file and some modification to the LocalSettings.php I was able to get it working:

.htaccess File:

RewriteEngine On
# Backward compatibility for old installation
RewriteRule ^wiki/index.php/(.*) http://intranet.netcare.at/$1 [R=301]
# Only rewrite uppercase Words because they signal the title for the pages to
# handle. Everything in lowercase is expected to be "internal"
RewriteRule ^([A-Z].*) index.php?title=$1 [L,QSA]

LocalSettings.php changes:

$wgScriptPath = "";
$wgScript = "/";
$wgArticlePath = "/$1";

This is simply a “it works for me” scenario. I did some testing and it seemed everything is working fine. However I also think the way I use Mediawiki just scratches the surfaces. We’ll see if it works out.

Entry Filed under: General

Leave a Comment

hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

August 2007
M T W T F S S
« Jul   Nov »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Most Recent Posts