Search Engine Friendly URL for MediaWiki

Posted on In Web

MediaWiki is the wiki-engine that runs Wikipedia. In this tutorial, we introduce how to configure search engine friendly URLs in MediaWiki.

==Search Engine Friendly URLs==

Default MediaWiki URLs look like www.example.com/w/index.php?title=TITLE which is a little ugly. To make it more search engine friendly, we will change it to SEO-friendly URLs like www.example.com/w/TITLE.

==Enabling Search Engine Friendly URLs==

”’Step 1.”’ Change the URL settings by using two configuration variables in LocalSettings.php: $wgScript and $wgArticlePath.

Open the LocalSettings.php (located in MediaWiki root folder) and append these lines:

$wgScript = "/w/";
$wgArticlePath = "$wgScript$1";

The $wgScript variable must contain path to the MediaWiki directory.

”’Step 2.”’ Create a .htaccess file in the installation folder ( /w/ ) of MediaWiki and put these lines:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?title=$1 [NC,L,QSA]

Then the MediaWiki’s URLs are more search engine friendly now.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *