IIS:如何将一个页面的请求重定向到另一个页面?

问题描述:

我已经编写了一个应用程序来替换单个页面,并且需要将旧页面的请求重定向到新应用程序。IIS:如何将一个页面的请求重定向到另一个页面?

在IIS中,我怎么会重定向请求

http://www.mysite.com/foo.aspx 

http://www.mysite.com/bar/default.aspx 

谢谢!

你需要的是URL重写。有很多选择。有些人在这个问题讨论:

IIS URL Rewriting vs URL Routing

在你的web.config做:

<configuration> 
<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="Foo_To_Bar" stopProcessing="true"> 
       <match url="^foo.aspx" /> 
       <action type="Redirect" url="/bar/default.aspx" redirectType="Temporary" /> 
      </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

如果你不想手工编写的重定向,还有一个URL重写和重定向工具:http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module安装程序说它是7.0版本,但它也适用于8.5。