【问题标题】:IIS URL rewrite - with dynamic filesIIS URL 重写 - 使用动态文件
【发布时间】:2015-07-13 18:02:59
【问题描述】:

我正在使用这个答案https://stackoverflow.com/a/13861795/848513,它非常适用于我的网站上不再存在的静态文件,以转发到新的文件位置。

但我也有一些需要转发到新位置的动态 URL,而以下代码似乎不起作用:

作品:

    <rule name="SpecificRedirect50" stopProcessing="true">
      <match url="aboutus.php" />   <!-- static URL -->
      <action type="Redirect" url="/about-us" redirectType="Permanent" />
    </rule>

不起作用:

    <rule name="SpecificRedirect1" stopProcessing="true">
      <match url="topic.php?id=39" />   <!-- dynamic URL-->
      <action type="Redirect" url="/folder/?id=520" redirectType="Permanent" />
    </rule>

我在尝试访问 www.site.com/topic.php?id=39 时遇到的错误是 404 Not Found 错误 - 即,它没有被重写脚本过滤。

格式应该是什么?

谢谢

【问题讨论】:

    标签: mod-rewrite iis-7


    【解决方案1】:

    好的,找到答案 - 这种格式有效:

        <rule name="SpecificRedirect1111" stopProcessing="true">
          <match url="^topic\.php$" />
            <conditions>
              <add input="{QUERY_STRING}" pattern="^id=39$" />
            </conditions>
          <action type="Redirect" url="/folder/?id=520" appendQueryString="false"  redirectType="Permanent" />
        </rule>
    

    【讨论】:

      猜你喜欢
      • 2021-11-06
      • 2022-08-22
      • 1970-01-01
      • 2012-10-31
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 2021-12-17
      • 2013-11-08
      相关资源
      最近更新 更多