我有网站(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/