IIS Mod-Rewrite solutions
Overview Documentation Download Purchase FAQ  
IIS Mod-Rewrite - URL rewrite tool for IIS

Short URLs for MediaWiki on IIS using .htaccess

23 Dec 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:

  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 MediaWiki root directory, 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. Make sure IIS has sufficient access rights to the file .htaccess. The user group IIS_WPG (if running on IIS 6), or the user group IIS_IUSRS (if running on IIS 7), or the current Application Pool's Identity User must have at least "read" access rights to the ".htaccess" file or to the directory that contains this file.

  8. Open with a text editor the file LocalSettings.php located in MediaWiki root directory.

  9. 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.

Download and try
IIS Mod-Rewrite

IIS rewrite

Download IIS Mod-Rewrite

Purchase IIS Mod-Rewrite