Warm tip: This article is reproduced from serverfault.com, please click

c#-将.aspx网址重定向到一个没有它的网址

(c# - Redirect .aspx url to one without it)

发布于 2020-11-28 16:27:36

我想使用IIS将URL从具有.aspx的旧URL重定向到一个没有它的URL。

例子:

  1. https://www.example.com/category.aspxhttps://www.example.com/category
  2. https://www.example.com/category.aspx?type=testhttps://www.example.com/category?type=test

我们可以使用IIS实现上述类型的重定向吗?请帮我解决一下这个。

提前致谢。

Questioner
vamsi penta
Viewed
11
mcbr 2020-11-29 02:25:12

你可以在带有URL重写模块的IIS中执行此操作你可以在IIS管理器中对其进行配置。文档中有一些示例此重定向规则应该起作用。

<rewrite>
    <rules>
        <rule name="Redirect from aspx" stopProcessing="true">
            <match url="^(.+?).aspx" />
            <action type="Redirect" url="{R:1}" appendQueryString="true" />
        </rule>
    </rules>
</rewrite>