Activities

September 2010
M T W T F S S
« Aug   Oct »
 12345
6789101112
13141516171819
20212223242526
27282930  

How do I convert .htaccess file to web.config

I have a requirement to re-define the apache re-write rule to IIS knowing language using web.xml on Windows 2008 server. There is one easy trick to achieve this.

Basic operations are,

1. Install Mod Rewrite component on II7
2. Create a website on IIS and import the .httaccess file

1. Installing Mod Rewrite Module

Download and install Mod Rewrite module from the following url according to your OS architecture.
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/. Then Close the IIS MMC and reopen it. Now you see that module is present as shown below

Then Click on ” import rules” label showing on the right side of the window tree. Find the .htaccess file and import and t hen click to apply. It will create/update the web.config file in the document root directory.

Here is the sample code which I used for re-writing Codeigniter frame work

It’s file name is “web.config

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”Imported Rule 1″ stopProcessing=”true”>
<match url=”^(.*)$” ignoreCase=”false” />
<conditions logicalGrouping=”MatchAll”>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” ignoreCase=”false” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” ignoreCase=”false” negate=”true” />
</conditions>
<action type=”Rewrite” url=”index.php/{R:1}” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>