IIS - URL Rewriting not working in IIS7 - Asked By BK Komal Komal on 09-Sep-11 08:13 AM

Hello,

We had developed application in 2.0 with URL rewriting. It's working find in IIS6 but we had just changed hosting to IIS7 but not url Rewriting not working please suggest how to fix this problem.

Thanks
Komal
Jitendra Faye replied to BK Komal Komal on 09-Sep-11 09:19 AM

There are several options for rewriting URL's on IIS, and users of IIS 7 are able to take advantage of Microsoft's own URL Rewrite module. In this guide we'll look at how you can use Microsoft's URL rewrite module to transparently redirect HTTP to HTTPS.


For this guide to work you'll need;

IIS 7 installed

Microsoft URL Rewrite Module installed

Create HTTPS bindings to your IIS website and assign certificate

Ensure Require SSL is NOT checked under SSL Settings for your website

Once you have this done you can simply copy and paste the following code between the <rules> and </rules> tags in your your web.config file in your website root directory.

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>


From here all you have to do is save your web.config file and test that the redirection is working.

From here all you have to do is save your file and test that the redirection is working.

Reena Jain replied to BK Komal Komal on 09-Sep-11 03:31 PM
hi,

url rewriter works fine in iis7, but some setting have to be involved in it,

some setting for isapi filter have to be added in the virtual directory's properties.

  • Created a new application pool for the site and set the mode to classic instead of integrated

the above trick solved the issue to an extent that the actual handler url started giving the response. the rewritten urls were still not responding and loading forever. I tried adding wildcard script mapping but to no avail.

I found a blog post suggesting me to use C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll instead of C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll and it started working on the server 


http://forums.iis.net/t/1092696.aspx

http://www.iis.net/expand/URLRewrite