c# - 将 URL 重定向或重写为新的

标签 c# iis model-view-controller

我有网站(ASP MVC,托管在 IIS 上)我想重定向的旧页面,但由于某种原因我没有正确处理。我也尝试使用 IIS 重写和 web.config。

例如,我有一个名为 https://www.tanalyzer.com/Home/FAQ 的旧页面我想将它重定向到 https://www.tanalyzer.com/faq

我在 web.config 中的内容是

<rule name="Rewrite rule1 for urls-old-to-new">
<match url=".*" />
<conditions>
<add input="{urls-old-to-new:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />

重写映射

   <rewriteMap name="urls-old-to-new"><add key="/Home/FAQ" value="/faq"></rewriteMap>

最佳答案

好的,我解决了这个问题

        <rule name="FAQ" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="Home/FAQ$" />
      <conditions>
      </conditions>
      <action type="Redirect" url="https://www.tanalyzer.com/faq" redirectType="Permanent" />
    </rule>

我现在在 web.config 中有 12 条规则,是不是太多了?

关于c# - 将 URL 重定向或重写为新的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45737051/

相关文章:

ios - 关于@selector 和 MVC

javascript - 使用 Ajax 和 $.each 获取复选框的值

iphone - 在 Objective-C 中创建对象数组。

c# - 编程字符串的表单资源使用情况?

c# - 来自 System.Data.SqlServerCe.Accessor.Dispose 的 SQLCE 3.5 SP2 NullReferenceException

c# - 未调用覆盖的虚函数

.net - 如何将超过 2Gb 的文件上传到 IIS 7.5/.Net 4?

iis - 负载平衡 ASP.NET 站点的架构建议

c# - 需要一些数学 - 投影斜率

windows - iis7 默认 mime 类型行为