@Blog.Author(Nandip Makwana) .LearningExperience(ASP.NET, ASP.NET MVC, IIS, jQuery & Technology Surrounding it...)

October 30, 2011 comment , ,

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.

In Actions pane of right side, click on import rules. It will open Import mod_rewrite rules screen.

Browse through .htaccess file and click on import button.

You can see summary of converted rules in tree view. You can also verify converted rules in XML view.

After verifying each rule click on apply in Actions pane.

That’s it, you have done. Now your all apache mod_rewrite rules are converted in IIS URL Rewrite rule and saved in web.config.

comments powered by Disqus

Featured Content

Resources & Tools

About Nandip Makwana

Nandip Makwana is passionate about digital world and web. He completed his Masters in Computer Application in June 2011. Currently he is working as a Software Engineer. He has shown great promise and command over ASP.NET and technologies surrounding it during his academic years and professorial life...continue reading