Go Back   NuHIT - SEO, Wiki, Forums > Wiki

MediaWiki SEF URLs

From Wiki

Out of the box MediaWiki URLs will look like this (assuming that your wiki is installed on http://www.yourdomain.com/wiki):


http://www.yourdomain.com/wiki/index.php/Main_Page


However, for Search Engine Optimization reasons, it is preferable to remove the 'index.php' from the URLs.


You can configure how MediaWiki links are generated.


There are multiple resources on the web with instructions on how to accomplish this. Links to these articles are included at the bottom.


This article describes one way to accomplish this, which is what we use here at nuHIT.com


Let's say that you want your URLs to look like this: http://www.yourdomain.com/wiki/Page_Title

To accomplish this, do the following:

1) Install MediaWiki in a directory other than the intended URL path.

1) Modify the Script Path used by MediaWiki

2) Modify .htaccess to rewrite URLs.


Contents

[edit] Install MediaWiki in a directory other than the intended URL path

While there are solutions that do not require this step, it is easier if your MediaWiki is installed in a different directory.


For instance, here at nuHIT.com, we wanted the URLs to look like this: http://www.nuhit.com/wiki/MediaWiki_SEF_URLs


So we installed MediaWiki in http://www.nuhit.com/w/


[edit] Script Path

Then you have to modify the Article Path that MediaWiki uses to generate URLs.


To modify the Article Path, open vbWikiPro_Init.php in your vbWiki Pro installation directory, and add the following line between the CUSTOM SETTINGS section:

$wgScriptPath = '/w';
$wgArticlePath = '/wiki/$1';


[edit] Modify .htaccess to rewrite URLs

Then you have to tell your server to forward all /wiki/* requests to MediaWiki's script.

There are many variants out there. The one included here is what we use at nuHIT.com.

To do this append the following to the .htaccess file found in your site's root (or create a new .htaccess if none exists)

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


You need to replace 'wiki' with the path used in 'Article Path' above, and 'w' with the path where MediaWiki is installed.

Notice that the .htaccess method only works for Apache Servers with the mod_rewrite handler installed. If you are using IIS, there is a URL rewrite ISAPI filter that can accomplish the same results.


[edit] External Sites

http://meta.wikimedia.org/wiki/Eliminating_index.php_from_the_url http://www.mediawiki.org/wiki/Manual:Short_URL http://meta.wikimedia.org/wiki/Using_a_very_short_URL


All times are GMT -4. The time now is 09:28 PM.