【问题标题】:Strip .html for a url redirect去除 .html 以进行 url 重定向
【发布时间】:2015-10-08 13:19:15
【问题描述】:

我正在从旧网站重定向到使用友好网址的新网站。

进入的网址是 example.com/news-events/some-news-story.html,它重定向到 anotherdomain.com/news/some-news-story

现在我建立的规则除了从末尾剥离 .html 以重定向到 anotherdomain.com/news/some-news-story.html 之外的所有内容。

这应该很简单,但我画的是空白。

规则如下:

<rules>
    <rule name="Redirect news posts" stopProcessing="true">
      <match url="^news-events/(.*)$" ignoreCase="false" />
      <action type="Redirect" redirectType="Permanent" url="http://www.anotherdomain.com/news/{R:1}" />
    </rule>
  </rules>

感谢任何帮助/建议。

【问题讨论】:

    标签: .net url redirect web-config url-redirection


    【解决方案1】:

    已通过在 URL 上运行此规则来解决此问题

    <rule name="removeextension" enabled="true">
          <match url=".*" negate="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{URL}" pattern="\." negate="true" />
          </conditions>
          <action type="Rewrite" url="{R:0}.html" />
        </rule>
    

    来自this site

    【讨论】:

      猜你喜欢
      • 2021-07-02
      • 2017-05-22
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-01
      • 1970-01-01
      相关资源
      最近更新 更多