How to mod_rewrite on IIS webserver

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]
</IfModule>

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

http://www.example.com/nr1/nr2/nr3/

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!

Antwort1

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)

Antwort2

Microsoft's Official IIS site has the Rewrite module you're looking for.

If you're familiar with mod_rewrite, the IIS equivalents are pretty similar. Otherwise there are plenty of guides around the net. The original intent of the module was to mirror mod_rewrite, so it's pretty similar though they have grown in slightly different directions.

verwandte Informationen