Pretty URLs in mediawiki
Filed in: web Add comments
The following steps are usually sufficient in order to make “pretty URLs” in mediawiki, e.g.
http://wiki.somehost.com/Article_Name
In Apache configuration:
RewriteEngine on RewriteCond %{REQUEST_URI} !^/(skins|stylesheets|images|config)/ RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php RewriteRule ^(.*)$ /index.php?title=$1 [L,QSA] |
In LocalSettings.php
$wgScriptPath = ""; $wgScript = "$wgScriptPath"; $wgRedirectScript = "$wgScriptPath/redirect.php"; $wgArticlePath = "$wgScript/$1"; |
However, the latest version (1.12.0 at the time of writing) needed the following patch, in order to make all things work. I don’t know whenever this was already reported by someone and/or fixed.
--- includes/Title.php.orig 2008-08-05 22:56:32.000000000 +0300 +++ includes/Title.php 2008-08-05 23:16:22.000000000 +0300 @@ -832,7 +832,12 @@ if ( $query == '-' ) { $query = ''; } - $url = "{$wgScript}?title={$dbkey}&{$query}"; + # Assume "pretty URLs" if wgScript is empty + if ( $wgScript == '' ) { + $url = "/{$dbkey}?{$query}"; + } else { + $url = "{$wgScript}?title={$dbkey}&{$query}"; + } } } |