IIS:如何将一个页面的请求重定向到另一个页面?
问题描述:
我已经编写了一个应用程序来替换单个页面,并且需要将旧页面的请求重定向到新应用程序。IIS:如何将一个页面的请求重定向到另一个页面?
在IIS中,我怎么会重定向请求
http://www.mysite.com/foo.aspx
到
http://www.mysite.com/bar/default.aspx
谢谢!
答
在你的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。