1

I'm using urlrewriting.net and want to add a rule to map all classic asp requests to default.aspx.

Unfortunately my attempt below just results in a redirect loop, so I must be doing something wrong.

    <add name="LegacyRedirect"
     virtualUrl="^~/(.*).asp"
     redirectMode="Permanent"
     redirect="Application"
     destinationUrl="~/default.aspx"/>

Many thanks, Ben

Ben Foster
  • 34,340
  • 40
  • 176
  • 285

2 Answers2

2
<add name="LegacyRedirect"
     virtualUrl="^~/(.*).asp"
     redirectMode="Permanent"
     redirect="Application"
     destinationUrl="~/default.aspx"
     processing="stop"
/>

Try that. And put this rule before all others. Processing = stop means once the rule has been matched, it doesn't apply any other rules.

Also,

destinationUrl="~/default.aspx"

can probably just be:

destinationUrl="~/"
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
  • Hi, unfortunately this also results in a redirect loop when requesting a standard page (e.g. default.aspx). It would appear that a request for an .aspx page is also matching the above rule. – Ben Foster Mar 24 '11 at 17:12
  • @Ben, what is your default page for the directory? Is it default.asp or default.aspx? If the default page is the ASP one it will non stop redirect – Tom Gullen Mar 24 '11 at 17:41
2

Seems I was missing $ at the end of my regular expression.

Below is what worked for me (redirects all asp requests to the site root):

    <add name="LegacyRedirect"
     virtualUrl="^~/([^?]*)\.asp$"
     redirectMode="Permanent"
     redirect="Application"
     destinationUrl="~/"/>
Ben Foster
  • 34,340
  • 40
  • 176
  • 285