【发布时间】:2019-12-13 10:43:43
【问题描述】:
在带有 URL 重写模块 2.0 的 IIS 10 上,我需要 2 条规则
1) HTTP 转 HTTPS
2) WWW 到非 WWW
第一个由空白规则模板创建。 对于第二个,我使用规范域名模板。
在我的 web.config 规则中是这样的:
<rewrite>
<rules>
<rule name="ForceHttps" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="CanonicalHostNameRule1" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^cooltechunder\.com$" negate="true" />
</conditions>
<action type="Redirect" url="https://cooltechunder.com/{R:1}" />
</rule>
</rules>
</rewrite>
所有案例都可以正常工作,除非有一个以:http://www 开头。
查看此图片以了解我的结果: https://i.imgur.com/h2l3Yw6.png
【问题讨论】:
标签: asp.net-core-2.2 url-rewrite-module iis-10