使用入站 IIS 规则我可以使用变量重定向到不同的 URL
https://www.cars.com/make/BMW/M3/index.html
https://www.cars.com/make/BMW/index.html#M3
我可以把它送到
https://www.cars.com/BWM.pdf#page=M3
IIS 规则
<rewrite>
<rules>
<rule name="CarModel">
<match url="(http|https):\/\/www.cars.com\/make\/\w+\/[0-9]+\/index.html" />
<action type="Redirect" url="https://www.cars.com/{Make}/{Make}.pdf#page={Model}" />
</rule>
</rules>
</rewrite>
更新到有条件的帖子,但仍然不会重定向
<rules>
<rule name="CarModel">
<match url="index.html" />
<conditions>
<add input="{HTTP_HOST}" pattern="(http|https):\/\/www.cars.com\/make\/\w+\/[0-9]+\/index.html" />
</conditions>
<action type="Redirect" url="https://www.cars.com/{R:3}/{R:3}.pdf#page={R:4}" />
</rule>
</rules>
我能够让它工作的唯一方法是重复规则和条件。# 根本不起作用;。
<rules>
<rule name="CarModel">
<match url="make\/\w+\/[0-9]+\/index.html" />
<conditions>
<add input="{HTTP_HOST}" pattern="make\/\w+\/[0-9]+\/index.html" />
</conditions>
<action type="Redirect" url="https://www.cars.com/{R:1}/{R:1}.pdf#page={R:2}" />
</rule>
</rules>
<rules>
<rule name="CarModelHash">
<match url="make\/\w+\/[0-9]+\/index.html#(.*" />
<conditions>
<add input="{HTTP_HOST}" pattern="make\/\w+\/[0-9]+\/index.html#(.*" />
</conditions>
<action type="Redirect" url="https://www.cars.com/{R:1}/{R:1}.pdf#page={R:2}" />
</rule>
</rules>