重定向或重写URL到新的
问题描述:
我有网站(ASP MVC,托管在IIS上)旧页面,我想重定向,但由于某种原因,我不明白。我尝试了IIS重写和web.config。重定向或重写URL到新的
,比如我有旧的一页称为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个规则,是不是太多了?
像这样的东西? https://stackoverflow.com/questions/41865181/c-net-mvc-route-aliasing – Ferryzijl
不,我正在寻找301 –