【问题标题】:redirect .aspx to Wordpress postname on a Microsoft IIS server (using web.config)将 .aspx 重定向到 Microsoft IIS 服务器上的 Wordpress 后缀名(使用 web.config)
【发布时间】:2023-03-12 15:52:01
【问题描述】:

我想重定向

www.example.com/category/product.aspx

www.example.com/category/product

www.example.com/page.aspx

www.example.com/page

在使用 web.config 的 Microsoft IIS 服务器上。

我是一个完整的 IIS 新手,感谢您的帮助。

【问题讨论】:

  • 你想要这个重定向专门针对这两个链接吗?还是要将其应用于所有链接?
  • 所有链接感谢@VictorLeontyev。

标签: asp.net iis url-redirection


【解决方案1】:

首先您需要为 IIS 安装 URL 重写模块。

1) 安装 URL 重写https://www.iis.net/downloads/microsoft/url-rewrite

2) 在你的web.config 添加规则

<rule name="Redirect aspx to non-aspx" stopProcessing="true">
    <match url="(.*).aspx$" />
    <action type="Redirect" url="{R:1}"/>
</rule> 

(这条规则应该在sections中->configuration -&gt; system.webServer -&gt; rewrite -&gt; rules如果你没有这个sections,那么你需要创建它)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-12
    • 2023-03-03
    • 2023-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-03
    • 2017-08-08
    相关资源
    最近更新 更多