Asp.net 将aspx页面重定向到其他页面
Windows Server 2008 R2。 我已经在我的服务器上安装了URL重写。在同一个站点中,我很难将一个页面重定向到另一个页面 我想重定向Asp.net 将aspx页面重定向到其他页面,asp.net,redirect,iis-7,windows-server-2008-r2,Asp.net,Redirect,Iis 7,Windows Server 2008 R2,Windows Server 2008 R2。 我已经在我的服务器上安装了URL重写。在同一个站点中,我很难将一个页面重定向到另一个页面 我想重定向 www.mysite.com/content/old/content.aspx 到 我已经尝试了一些方法来实现这一点,但事实证明比我想象的要困难得多。我怎么能只重定向一页 我试过了 <rewrite> <rewriteMaps configSource="Web.RewriteMaps.config"/>
www.mysite.com/content/old/content.aspx
到
我已经尝试了一些方法来实现这一点,但事实证明比我想象的要困难得多。我怎么能只重定向一页
我试过了
<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>
您可以使用
Response.Redirect(“www.mysite.com/content/new/content.aspx?id=1&sid=2”)代码>
在您想要使用的任何事件中编写此代码
例如:
我们还可以使用javascript进行导航
window.location = "window.location = "SomePage.aspx";
另一种方法是在asp.net应用程序的web.config中添加类似的内容(这将允许动态页面:
<system.webServer>
<httpRedirect enabled="true" destination="www.mysite.com/content/new/content.aspx?id=1&sid=2" />
我不确定。因为我是从这个网站上得到的。请也尝试一下。最终找到了应该怎么做
<rewrite>
<rules>
<rule name="redirect single page" patternSyntax="ExactMatch" stopProcessing="true">
<match url="old.aspx" />
<action type="Redirect" url="URL/page.aspx" appendQueryString="false" />
</rule>
</rules>
</rewrite>
根据您的陈述“我已经尝试了几种方法”,您尝试过的内容应该被添加到问题中。从您的回答来看,似乎有不止一种方法可以实现这一点?我尝试创建一个空白规则,并选择我认为相关的选项,即请求的URL=匹配模式,使用精确匹配(但要么出错,要么我无法保存)。您能告诉我您认为哪种方式才是正确的方式吗?我无法这样做,因为我无法访问代码隐藏文件。我希望在IIS中执行此操作,请查看此链接。我看到了指向的链接,但它将目录重定向到页面,而不是页面重定向到页面(除非我遗漏了什么?)
<system.webServer>
<httpRedirect enabled="true" destination="www.mysite.com/content/new/content.aspx?id=1&sid=2" />
<rewrite>
<rules>
<rule name="redirect single page" patternSyntax="ExactMatch" stopProcessing="true">
<match url="old.aspx" />
<action type="Redirect" url="URL/page.aspx" appendQueryString="false" />
</rule>
</rules>
</rewrite>