我需要将带有变量哈希码的url重定向到IIS10中具有相同哈希码的另一个url (WindowsServer2019)。
示例:
https://www.example.com/hello/sd54effg1g5s11d5111dwds21fds2f1ffd需要重定向到:
https://subdomain.example.com/hello/sd54effg1g5s11d5111dwds21fds2f1ffd目前,我在web.config中有这样的规则:
<rule name="rulename" stopProcessing="true">
<match url="^hello/[a-zA-Z0-9]+$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(https:\/\/www\.)example.com$" />
</conditions>
<action type="Redirect" url="https://subdomain.{HTTP_HOST}/{R:1}" />
</rule>发布于 2019-11-15 05:58:06
首先,{HTTP_HOST} is将与url中的https部分不匹配。因此,您应该使用^www.example.com$而不是^(https:\/\/www\.)example.com$。
此外,您应该使用https://subdomain.example.com/{R:1}而不是https://subdomain.{HTTP_HOST}/{R:1}来实现您的需求。
详细信息,请参阅下面的url重写规则:
<rule name="rulename" stopProcessing="true">
<match url="^hello/[a-zA-Z0-9]+$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.example.com$" />
</conditions>
<action type="Redirect" url="https://subdomain.example.com/{R:0}" />
</rule>https://stackoverflow.com/questions/58855712
复制相似问题