“How can I redirect /default.aspx to / on IIS shared hosting without causing an endless loop?”
It’s a familiar problem with Windows Web Servers. If you just try to apply a 301 redirect rule to the default document in IIS (which is usually a .NET page named Default.aspx) to send reqeusts back to the domain root, it will result in an endless loop of sending visitors back and forth between the two URIs. http://www.yourdomain.com/ will redirect to http://www.yourdomain.com/Default.aspx (which is built-in behavior in IIS), and http://www.yourdomain.com/Default.aspx will just keep redirecting back to http://www.yourdomain.com/.
I had noticed this when working with IIS 6, but never really found an acceptable solution. Being aware that Microsoft released the URL Rewrite Extension for IIS 7 last month, I figured I may as well ask someone in the know about it, so I emailed Bill Staples (GM of the Microsoft Web Platform) if he knew how this could be accomplished.
He sent my request to Ruslan Yakushev, the Project Manager for URL Rewriter whom he refers to as “a master at how to use it.” I was very happy to get an email back from Ruslan with a solution made possible (and extremely simple) thanks to the URL Rewrite extenstion:
<rule name="Redirect" patternSyntax="Wildcard" stopProcessing="true">
<match url="default.aspx" />
<action type="Redirect" url="/" redirectType="Permanent" />
While this will rather eloquently solve the issue if you administer IIS 7 on your server and can install the Microsoft module for URL Rewriting, it doesn’t necessarily answer Michael’s question on how to correct this problem on a shared server (i.e., one where the host may not install an IIS extenstion module for you). It also won’t help anyone still using IIS 6; so if anyone out there has a workaround they’ve found for this issue, by all means please comment on this post or email it to me and I’ll publish it.