URL Rewrite using Apache rules Under IIS7

February 21st, 2010

I got URL rewrite to work. I got managed fusion rewriter to work since it seems like a better solution and uses the same syntax as you would use mod_rewrite on Apache.

Here’s what I did. Make a “bin” folder under IIS settings under hosting settings in godaddy. Setup the folder with non of the checkboxes selected for security reasons. If you already have the folder online. I would delete it, wait for godaddy system to make it, then drop your files in there. Drop the .dll and .pbd file for managed fusion rewriter to work. Godaddy takes time to make the bin folder, might take 15 minutes. It will tell you on there pending setup and the folder will appear when done in the ftp.

Next setup the web.config file. Throw this inbetween <configuration></configuration> tags:
<configSections>
<section name="managedFusion.rewriter" type="ManagedFusion.Rewriter.Configuration.ManagedFusionRewriterSectionGroup" />
</configSections>

You may run into errors in this process of modifying the web.config file. You might see stuff like http error code 500 errors, this error is because the way you wrote the XML file web.config is wrong. Make sure ampersands and other junk are URL encoded. Also make sure you are inserting in stuff where it is supposed to be.

Another common error is “Object reference not set to an instance of an object” This is I fixed by moving the <configSections></configSections up and down, it ended up working when I put it up top right below the beginning <configuration> tag. The order matters apparently.

Also you need to add this between <system.webServer></system.webServer> if you are running IIS7, if you are using a different version, refer to the documentation of managed fusion rewriter:

<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<add name="RewriterModule" type="ManagedFusion.Rewriter.RewriterModule, ManagedFusion.Rewriter"/>
</modules>
<handlers>
<add name="RewriterProxyHandler" preCondition="integratedMode" verb="*" path="RewriterProxy.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>

If you don’t have a <system.webServer></system.webServer> tag, create it and place it in between <configuration></configuration>

In the process it may help if you also throw this inbetween <system.webServer></system.webServer>:

<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>

And I had this just before </system.web> although I don’t think you need the defaultRedirect attribute in this case:

<customErrors mode="Off" defaultRedirect="Error.aspx"></customErrors>

Similar Posts
Posted in Web Engineering

One Response to “URL Rewrite using Apache rules Under IIS7”

  1. [...] plays true in any kind of IT activity, networking, etc. When programming you often come across a logical problem which becomes a road block and you can’t pass that road block until you solve the problem. Rushing through the road [...]

Comments