Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 300
joelmdev Avatar asked Apr 06 '11 19:04

joelmdev


1 Answers

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

<match url=".*" />
like image 98
Matt Avatar answered Oct 27 '22 20:10

Matt