MediaWiki: URL beautification HowTo
November 27th 2008
This is ugly! Following instructions at the MediaWiki.org site, you can make it simpler and nicer:
To achieve that, add the following to /etc/apache2/httpd.conf:
Alias /wiki /usr/share/mediawiki/index.php
Then add/modify the following at /var/lib/mediawiki/LocalSettings.php (again, Debian default path):
$wgArticlePath = '/wiki/$1'; # This directory MUST be different from $wgScriptPath
$wgUsePathInfo = true;
Recall that you must have two "directories", which in the example above are /w and /wiki. The former is "real" and the latter is "virtual".
The real dir (the one used as value for $wgScriptPath) must contain the MediaWiki files, thus it must point to the /usr/share/mediawiki dir. To this end, it must either exist in the Apache root (usually /var/www/), or be an alias. If you follow the first route, you can make a link, like in the following example:
The second route would imply adding this line to /etc/apache2/httpd.conf:
The latter requires restarting the Apache daemon, but I personally prefer it.
The virtual dir (the one used as value for $wgArticlePath) will be our path to get rid of the URL ugliness, and point directly to an article's title. As such, it must be aliased in /etc/apache2/httpd.conf adding the following line to it, as mentioned above:
Finally, you shold enable the
rewrite PHP module, if it's not enable already, and reload Apache:
% ln -s ../mods-available/rewrite.load .
% /etc/init.d/apache2 reload
After that, pointing to website/wiki/somearticle should lead you to the wiki page for somearticle. For more information, refer to the MediaWiki.org site.Tags: en, howto, HTML, internet, mediawiki, optimization, Wikipedia
2 Comments »