Monday, December 19, 2011

Import Apache mod_rewrite Rules in IIS 7

     With Microsoft's Web Stack, many PHP applications are now hosted on IIS. As PHP is an open source, one of the advantages of using PHP is that you will find plenty of free script for ready to use. And basically these all ready to use scripts are written for LAMP model, so we might face some problem related to web server (Apache vs IIS) configuration while running these scripts on IIS. Recently one of my friend face similar problem with Apache rewrite rules while he deployed ready to use PHP script on IIS, and asked me to resolve it.

We need to convert apache mod_rewrite rules into IIS URL Rewrite rules to deploy PHP application on IIS. We can accomplish this task in two ways.


First way

Open .htaccess file of PHP and manually convert each apache mod_rewrite rule in IIS URL Rewrite rule and then save it in web.config. Now loop through above process for total number of apache mod_rewrite rule ;)


Smarter way

Instead of manually loop through each apache mod_rewrite rule and converting it in IIS URL Rewrite rule, we can automate this process with IIS URL Rewrite Module. Earlier in one post we have seen how we can use IIS URL Rewrite Module to set preferred domain. Following is the steps for converting apache mod_rewrite rules into IIS URL Rewrite rules.

Open URL Rewrite Module in IIS.

1.png

Read more: dotnetExpertGuide.com
QR: import-apache-modrewrite-rules-iis-7.html

Posted via email from Jasper-Net