【发布时间】:2016-02-11 11:02:50
【问题描述】:
Windows Server 2008 R2。
我已经在我的服务器上安装了 URL Rewrite。我在将一个页面重定向到同一站点中的另一个页面时遇到困难,例如
我想重定向
www.mysite.com/content/old/content.aspx
到
www.mysite.com/content/new/content.aspx?id=1&sid=2
我已经尝试了几种方法来实现这一点,但事实证明比我想象的要困难。我怎么能只重定向一页?
我试过了
<rewrite>
<rewriteMaps configSource="Web.RewriteMaps.config"/>
<rules>
<rule name="Old Page Redirects" stopProcessing="true">
<match url=".*"/>
<conditions>
<add input="{OldPages:{REQUEST_URI}}" pattern="(.+)"/>
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
在我的配置文件中
<rewriteMaps>
<rewriteMap name="OldPages">
<add key="/content/old/content.aspx" value="/content/new/content.aspx?id=1&sid=2" />
</rewriteMap>
</rewriteMaps>
【问题讨论】:
-
根据您的陈述“我尝试了几种方法”您尝试了什么应该添加问题。
-
从您的回复来看,似乎有不止一种方法可以实现这一点?我尝试创建一个空白规则并选择我认为相关的选项,即请求的 URL = 匹配模式,使用完全匹配(但出现错误或我无法保存)。您能建议您认为哪种方式是正确的方式吗?
标签: asp.net redirect iis-7 windows-server-2008-r2