Dienstag, 22. Oktober 2013

pretty URL in mediawiki

For my personal homepage http://www.staerk.de/thorsten I use mediawiki. That way I can edit it whenever I want, even from an internet cafe or the like.

When I write about e.g. my Cybermaster I do not want it to appear anywhere but on http://www.staerk.de/thorsten/cybermaster. This is called a prettyURL and I want to show here how I do it. My URL http://www.staerk.de/thorsten corresponds to the directory /var/www/staerk.de/thorsten on the server. I am using mediawiki 1.21.2 on Apache2 under Ubuntu Linux 10.04
  • make sure Apache has the "rewrite" module loaded:
    # apache2ctl -t -D DUMP_MODULES 2>&1 | grep rewrite
    rewrite_module (shared)
  • configure apache to rewrite your requests as discussed here:
    RewriteRule ^/?thorsten(/.*)?$ %{DOCUMENT_ROOT}/thorsten/index.php [L]

    RewriteRule ^/*$ %{DOCUMENT_ROOT}/thorsten/index.php [L]

  • restart apache
    /etc/init.d/apache2 restart
  • Add the following line to LocalSettings.php:
    $wgArticlePath = "/thorsten/$1";

Now your wiki will look "strange" like this:

The reason for this "strange" look is that the skins are missing. Mediawiki is using a file called load.php and when loading it, apache will use its rewrite-rules and try to load it as a wiki page. The solution is:
  • add the following condition above the first rewrite rule:
    RewriteCond %{REQUEST_URI} !^/thorsten/load.*$

Then it looks better, but still the images are missing. No problem, reading apache's access log at /var/log/apache2/other_vhosts_access.log I find that clients try to download them from /thorsten/Images. So
  • add another condition above the rewrite rule:
    RewriteCond %{REQUEST_URI} !^/thorsten/images.*$

and the page looks again as it should:

See also

Keine Kommentare:

Kommentar veröffentlichen

Raspberry Pi, test my internet connection

Since start of Corona times, I use my internet at home also for work. So its reliability and performance has become crucial. Performance see...