我有这个代码
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain\.com\.au$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.domain.com.au/{R:1}" />
</rule>
<rule name="CanonicalHostNameRule2">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain\.co\.nz$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.domain.co.nz/{R:1}" />
</rule>
当我运行这个时,我得到“这个网页有一个重定向循环”似乎 NZ 出于某种原因重定向到 AU。
更新
这似乎有效
<rule name="RedirectToWWW" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(?!www)(\S+)\.(co(\.nz)?|com\.au)$" />
</conditions>
<action type="Redirect" url="http://www.{C:0}/{R:0}" />
</rule>