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

Search Engine Friendly (SEF) URLs for IIS using .htaccess

12 Jun 2007
Joomla, Wordpress, and Drupal users should follow the guides listed below:

Most of the popular content management systems (CMS), blog engines, and forum engines, such as Wordpress, Joomla etc., support search engine friendly URLs, to improve search engine optimization (SEO) level. The majority of them rely on URL Rewriting provided by Apache mod_rewrite. In most cases, the URL Rewriting configuration script is in a .htaccess file within the application's root directory.

This feature was considered for a long time to be a privilege of Apache users that had mod_rewrite enabled. Nowadays, IIS Mod-Rewrite Pro brings this ability to IIS, by enabling URL rewriting on the fly, in the same exact way as it is done with Apache mod_rewrite. Additionally, it supports .htaccess configurations, covering all the requirements to enable SEF URLs on those web applications.

Configuration summary

The configuration procedure is fairly easy and includes the following 4 steps:
  • Download and install IIS Mod-Rewrite Pro on your server.
  • If your web application is PHP based, add the following line of code at the beginning of index.php:
    This line of code fixes a IIS/Apache compatibility issue at application level.
  • Open your web application's admin panel and enable SEF URLs.
  • Make sure the appropriate .htaccess file with the rewrite rules exists in your web application's root directory.

Installing IIS Mod-Rewrite Pro

The IIS Mod-Rewrite installation procedure is quite easy. Simply download IIS Mod-Rewrite Pro, uncompress the downloaded file, and run setup.exe. That's it!

It is important that you download the Pro version, because only this version supports .htaccess.

Adding compatibility code in index.php

It is important in many blog, CSM, or forum engines that you add the following line of code at the beginning of index.php in the web app's root directory.


The right place in index.php is in the next line, right after the opening tag <?php at the head of the script.

The addition of this line is necessary in most cases, because most clean permalink mechanisms rely on apache's server variable REQUEST_URI, which contains the originally requested URI. This server variable is not supported by IIS, but with the addition of this code line this problem gets fixed.

Note: In IIS Mod-Rewrite Control Center, you must have "Add original URL HTTP header" enabled with the value "X-Original-URL". This is the default setting when IIS Mod-Rewrite is installed.

.htaccess file

A typical configuration deployed by most blog, CMS, or forum engines is the following:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

However, every web application has special rewriting requirements, so you should use the rules in the .htaccess file deployed with the web application.

Note that when refering to the .htaccess file we mean the actual filename and not just the filename extension. If your web application's distribution contains the .htaccess file with a different name (e.g. htaccess.txt, htaccess.dist etc), you must rename it to ".htaccess". Since Windows Explorer will not allow such a filename, you must open the Command Prompt window (cmd.exe), change directory (cd) to the web application's root, and rename the file using the following command:

rename  htaccess.txt  .htaccess

Tested web applications

This solution is tested with absolute success with the following web applications:

The list above will keep growing as we are continuously testing various CMS, blog, and forum engines...

Download and try
IIS Mod-Rewrite

IIS rewrite

Download IIS Mod-Rewrite

Purchase IIS Mod-Rewrite