4

I am converting my website from Asp.Net Webforms to Asp.Net MVC. I want to redirect all my old .aspx files to drop the .aspx. I run IIS7 with the Url Rewrite module installed.

Example:

/about.aspx -> /about

The user will go to http://www.site.com/about.aspx and I want them redirected to http://www.site.com/about.

How do I do this using Url Rewrite? I don't want to have to do to each .aspx and put a meta-redirect in.

Martin
  • 11,031
  • 8
  • 50
  • 77
  • Do you want a user entering in the url of site.com/about.aspx to redirect to the about controller or a user entering site.com/about to redirect to the about aspx page? – Odd Jan 19 '10 at 01:39

1 Answers1

2

In your web.config file in system.webServer configuration section add:

<rewrite>
  <rules>
    <rule name="WebFromsToMVC" stopProcessing="true">
      <match url="^(.*?)\.aspx\?*?.*$" />
        <conditions>
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
      <action type="Rewrite" url="{R:1}" />
    </rule>
  </rules>
</rewrite>
Branislav Abadjimarinov
  • 5,101
  • 3
  • 35
  • 44