代码之家  ›  专栏  ›  技术社区  ›  user1670953

使用IIS 7进行URL重定向

  •  0
  • user1670953  · 技术社区  · 10 年前

    我希望将特定文件夹及其子文件夹中的所有页面重定向到根文件夹上的页面。我在IIS 7.5中编写了以下规则,但它不起作用。请告知。

    <rule name="someName" stopProcessing="true">
    <match url="/MoveFromThisFolder/.*" />
    <action type="Rewrite" url="/ToThisFile.html" appendQueryString="false" />
    </rule>
    
    2 回复  |  直到 10 年前
        1
  •  1
  •   user1670953    10 年前

    我修改了规则如下,它对我有效!

    <rule name=“SomeRule”stopProcessing=“true”>
    <match url=“^FromThisFolder/(.*)”/>
    <action type=“Redirect”url=“ToThisFile.html”appendQueryString=“false”/>
    </规则>

        2
  •  -1
  •   badazzhindu    10 年前

    尝试去掉前导词“/”

    <rule name="someName" stopProcessing="true">
    <match url="^MoveFromThisFolder/($|[\?/].*)" />
    <action type="Rewrite" url="ToThisFile.html" appendQueryString="false" />
    </rule>