from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< MediaWiki‎ | archive‎ | customizing
Revision as of 02:14, 5 November 2007 by Woozle (talk | contribs) (Reverted edits by (Talk); changed back to last version by Woozle)
Jump to navigation Jump to search


computing: software: web: MediaWiki: customization: shortening MediaWiki URLs


The most reliable method seems to be the mod_rewrite, which requires access to either httpd.conf or requires particular handling options for .htaccess to be switched on (fortunately, they usually seem to be). Failing that, another method is:

Some additional methods are documented here.

Using mod_rewrite

This is probably documented elsewhere, but this is what actually worked on a shared server without root access or a shell.

This assumes MediaWiki is installed in the root of the www pages, e.g. is the wiki's main page.

First, the .htaccess file needs to include:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Second, modify LocalSettings.php:

$wgArticlePath = "/$1";

Then do ?action=purge on any page to test it. Internal links on existing pages will convert to the new URLs any time they are saved or purged.

The above seems to work for everything (including editing) without breaking old-style URLs, and may offer clues as to how to fix the minor problems which make the 404 method (below) unusable.

This method is also documented here, with some minor changes:

Wish list:

  • proper handling of page named .htaccess (click on that for a demonstration of the problem)
  • ability to have the wiki installed in a subdirectory while still making it appear to be in the domain's root folder


Please feel free to post comments here or on the Talk page if you try any of these procedures.

6/23/2007: I used your .htaccess and then set $wgArticlePath = "$wgScriptPath/$1";. This way the forwarding works regardless of what directory the wiki is located in. In my case it was /wiki. --Jordan Mendler (jmendlerspam@spamuclaspam.spamedu)