【发布时间】:2018-11-13 11:36:59
【问题描述】:
我有以下规则,可以很好地将我的 www 请求重定向到根目录。
但是我似乎无法为 localhost 关闭它。这是我现在拥有的:
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" />
</rule>
我尝试了很多方法,包括:
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^localhost$" negate="true" />
<add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" />
</rule>
你能帮忙吗?正则表达式是我的弱点,唉
【问题讨论】:
-
检查this post。
-
@WiktorStribiżew 我尝试添加一个条件
但这不起作用?我做错了什么? -
也许你需要使用
<rule name="CanonicalHostNameRule1" stopProcessing="true">? -
不,不幸的是它不起作用......
-
您是否尝试过将
localhost作为您的模式
标签: regex iis isapi-rewrite