我在端口80和443上有一个用于站点web.test.com的IIS,它用作在端口8090上同一服务器上配置的另一个Web服务器的反向代理。因此,我在使用IIS重写模块和ARR遵循以下规则的模块。
<rule name="RULE1" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="web.test.com" />
</conditions>
<action type="Rewrite" url="http://localhost:8090/{R:1}" />
</rule>
我想添加一个重定向(或扩展重写),如果有人直接访问web.test.com,则URL被重写/重定向到web.test.com/foo/index.html?bar(从技术上讲,这是localhost:8090 / foo / index.html?bar)-因此它应该转到子URL中的文件,然后在URL中添加URL参数。
没有人知道如何执行此操作。我找到了很多有关如何重定向的说明,但从未与反向代理结合使用。
提前谢谢您
您可以创建重定向规则,然后在反向代理规则之前将重定向规则上移。
<rule name="Redirect Rule" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{URL}" pattern="^(/)?$" />
</conditions>
<action type="Redirect" url="/foo/index.html?bar" redirectType="Temporary" />
</rule>
<rule name="RULE1" enabled="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="domain.com" />
</conditions>
<action type="Rewrite" url="http://localhost:8090/{R:1}" />
</rule>