我有.net MVC应用程序。我们正在尝试将一个旧Url重定向到一个新Url。
示例:旧链接https://www.example.com/App/Home/Index新链接https://www.example.com/Home/Index
我试着用URL重写模块来解决这个问题,但是应用程序一直告诉我找不到Controller。
以下是我尝试过的:
<rewrite>
<rules>
<rule name="CARES2" patternSyntax="ExactMatch" stopProcessing="true">
<match url="https://www.example.com/App/Home/Index" />
<action type="Rewrite" url="https://www.example.com/Home/Index" logRewrittenUrl="true" />
<conditions logicalGrouping="MatchAny">
</conditions>
</rule>
</rules>
</rewrite>发布于 2022-10-27 07:03:05
我试着对我的规则进行测试,发现下面的规则按照您的要求工作。
<rewrite>
<rules>
<rule name="old to new" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/app/Home/Index" />
</conditions>
<action type="Redirect" url="https://www.example.com/Home/Index" />
</rule>
</rules>
</rewrite>输出:

您可以尝试使用它进行测试,并根据您的需求修改规则。
https://stackoverflow.com/questions/74212247
复制相似问题