web.config实现http重定向跳转HTTPS,代码如下:
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
web.config重定向带www的域名转向www域名规则,代码如下:
<rule name="不带www转向www域名规则" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^mobanjia.cn$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://www.mobanjia.cn{R:1}" redirectType="Found" />
</rule>
模板家跳转使用的是如下代码:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="不带www转向www域名规则" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^mobanjia.cn$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://www.mobanjia.cn/{R:1}" redirectType="Found" />
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>