Micronovae
Home Products Downloads Purchase Support Company
Overview Documentation Download Purchase FAQ
 
IIS Mod-Rewrite

Short URLs for MediaWiki on IIS using .htaccess

7 Apr 2008

This article describes a detailed, step-by-step guide for enabling Short URLs on MediaWiki on IIS web server

This solution requires IIS Mod-Rewrite Pro and IIS 6.0 or later, and it is tested with MediaWiki 1.12, PHP 5.2.4, and MySQL 5.0.24.

To enable Short URLs on MediaWiki on IIS, follow these steps:

  IIS Mod-Rewrite

Download IIS Mod-Rewrite

Purchase IIS Mod-Rewrite
  1. Install PHP following the vendor's instructions.

  2. Install MySQL Server following the vendor's instructions.

  3. Install IIS Mod-Rewrite Pro (download).

  4. If on production environment, activate IIS Mod-Rewrite using a valid license key. If activation is skipped, IIS Mod-Rewrite will work in test mode and you will need to restart IIS every 30 minutes or 1000 requests, if your testing exceeds these limits.

  5. Install MediaWiki according to the vendor's instructions.

  6. Create a new file with filename ".htaccess" in the root of you MediaWiki installation, and copy using a text editor the following configuration in it:

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

  7. Open with a text editor the file "LocalSettings.php", located in MediaWiki root directory.

  8. Locate the variable $wgScriptPath, and add the following line of code right next to it:

    $wgArticlePath = $wgScriptPath . '/$1';

    After adding this line, the code should look like this:

    ...
    ...
    $wgScriptPath = "/wikipath";
    $wgArticlePath = $wgScriptPath . "/$1";
    ...
    ...


    where wikipath is the root URL of you MediaWiki installation.

After, completing all the steps above, your MediaWiki installation will fully serve Short URLs, and your website's SEO will be drastically improved.