Short URLs in MediaWiki

Revision as of 22:45, 18 January 2008 by Belminf (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

So I wanted to make the URLs in this Wiki nicer and shorter. After searching around, the modifications below are the ones that worked for me (using MediaWiki 1.9.3 and Apache 2.2.6).

Now, as oppose to:
http://wiki.bfworks.com/index.php/Article_Name

I could distribute:
http://wiki.bfworks.com/Article_Name

LocalSettings.php settings

LocalSettings.php is located in the root of the MediaWiki installation. Search for these values and set them to the value described below.

$wgScriptPath        = "";
$wgScript            = "$wgScriptPath/index.php";
$wgRedirectScript    = "$wgScriptPath/redirect.php";
$wgArticlePath       = "$wgScriptPath/$1";

.htaccess content

.htaccess file is processed by Apache. You need to have mod_rewrite installed.

<IfModule mod_rewrite.c>

# Turn rewrite engine on
RewriteEngine On

# Only if file or directory do not exist
RewriteCond %{REQUEST_FILENAME}  !-f
RewriteCond %{REQUEST_FILENAME}  !-d
RewriteRule ^(.*)$      /index.php/$1 [L]

</IfModule>