Search Engine Friendly URL for MediaWiki
Posted on In WebMediaWiki 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.