IIS 重定向

IIS redirection

我正在尝试在 IIS 中设置重定向,但没有成功。由于某种原因,它什么都不做。

我需要达到的目标:

在整个互联网上进行了研究,尝试了很多不同的方法,仍然没有运气。

将规则添加到 web.config 文件并通过 IIS URL 重写。

这是我的代码。希望有人能帮忙。谢谢。

<rewrite>
        <rules>         
            <rule name="staff redirect" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="/staff(.*)$" />
                </conditions>
                <action type="Redirect" url="/{C:1}" appendQueryString="true" />
            </rule>
            
            <rule name="www redirect" enabled="true" stopProcessing="true">
              <match url="(.*)" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTP_HOST}" pattern="(www\.)(.*)$" />
              </conditions>
                <action type="Redirect" url="https://{C:2}" appendQueryString="true" />
            </rule>             
        </rules>
    </rewrite>

您可以使用此 URL 重写规则:

      <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="(staff)(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_HOST}" pattern="^www\.example\.com" ignoreCase="false" />
                    </conditions>
                    <action type="Redirect" url="http://example.com{R:2}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>