URL Rewrite 配置下载

我们也可以手动下载URL Rewrite插件,这是官方地址:URL Rewrite下载

安装完成后,webconfig添加如下配置。

<rewrite>
<rules>
<rule name="HostNameRule1">
<match url="(.*)" />
<!--匹配所有条件-->
<conditions logicalGrouping="MatchAny">
<!--当不是使用https协议访问的时候-->
<add input="{HTTPS}" pattern="^OFF$" />
<!--并且访问的host不是potekelec.com这种,例如www.potekelec.com-->
<add input="{HTTP_HOST}" pattern="^www\.********\.com$" negate="true" />
</conditions>
<!--跳转到https-->
<action type="Redirect" url="https://www.********.com/{R:1}" redirectType="Permanent" />
</rule>
<rule name="HTTPS redirect">
<match url="(.*)" />
<conditions>
<!--当使用HTTPS协议访问-->
<add input="{HTTPS}" pattern="^ON$" />
<!--当访问 https://potekelec.com的时候-->
<add input="{HTTP_HOST}" pattern="^www\.********\.com$" negate="true" />
</conditions>
<!--跳转到HTTPS-->
<action type="Redirect" url="https://www.********.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>

猜你喜欢

转载自www.cnblogs.com/tianlong/p/12175817.html