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 Rewri开发者_运维百科te 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.
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>
精彩评论