Nov 21, 2011

How to mod_rewrite on IIS webserver


As my previous server was a Linux powered machine I have this piece of code:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?path=$1 [NS,L]

This piece of code will put the information in the URL like this:

into an array like this:

array ( 0 => "nr1", 1 => "nr2", 2 => "nr3")

My new server machine is an Windows 2008 (IIS) based server. Now i would like to use the mod_rewrite mod on my new server aswell. In short my question is:

Can anyone tell me, or link me to a tutorial that tells me, how to install/use the mod_rewrite mod (or any mod that does the same thing) and translate the code above into a format i can use on my windows based server.

I still use php, not ASP.NET, I know many people will say use apache or something, but IIS usage is needed unfortunately.

Many thanks in advance!


I quite like the IIS Rewrite Module because it’s fully integrated into the web.config file (the IIS equivalent of .htaccess).

But if you’re after an exact syntax match, ISAPI Rewrite is your friend. It has (as far as I can tell anyway) 100% compatibility with Apache’s mod_rewrite module in a .htaccess file (and actually uses a .htaccess file which looks really weird in Windows Explorer to see a valid file without a filename)

Related posts:

  1. Apache web server with the mod_rewrite module
  2. mod_rewrite is not being enabled?
  3. Apache mod_proxy vs mod_rewrite
  4. Mod_rewrite question – what does this code for files do?
  5. mod_rewrite not working for me

Leave a comment