joelmdev joelmdev - 2 months ago 6
ASP.NET (C#) Question

Use IIS7 URL Rewriting to redirect all requests

I have a .NET site that I am taking down and I plan on redirecting all requests to 'www.mysite.com' using a rewrite rule in the web.config. Should be a simple task, but it's not. I've removed all the content from the filesystem except a single Default.aspx page and a default web.config with the following rewrite rule:

<rule name="Redirect All" stopProcessing="true">
<match url="^(www\.)?mysite\.com(/.+)$" />
<action type="Redirect" url="www.mysite.com" appendQueryString="false" />
</rule>


If I request www.mysite.com/garbage.aspx the server is still trying to look up garbage.aspx, or any other url I provide just as if the rewrite rule was not there.
Very frustrating. Ideas?

Answer

Do you want to redirect ALL requests to your new site? If so, this should do it:

<match url=".*" />