辣椒云.虚拟主机专区

美国虚拟主机

美国空间特别适合外贸公司使用,免备案! 另有港台虚拟主机可选。

web.config设置http重定向301到https方法

特别提示:网站一定要安装SSL证书情况下,并且直接访问HTTPS能生效情况下才设置http转https的301重定向,不然生效了由于HTTPS本身不可访问

特别提示:网站一定要安装SSL证书情况下,并且直接访问HTTPS能生效情况下才设置http转https的301重定向,不然生效了由于HTTPS本身不可访问,这样虽然设置重定向成功了,但网站没有正确安装SSL证书会造成无法打开。

IIS下web.config配置HTTP跳转https 301永久重定向代码:

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<httpErrors>
<remove statusCode=”404″ subStatusCode=”-1″ />
<error statusCode=”404″ prefixLanguageFilePath=”” path=”/404.html” responseMode=”ExecuteURL” />
</httpErrors>
<rewrite>
<rules>
<rule name=”Imported Rule 1″>
<match url=”(.*)” />
<conditions logicalGrouping=”MatchAll”>
<add input=”{HTTP_HOST}” pattern=”^sleep-vip.cn$” ignoreCase=”false” />
</conditions>
<action type=”Redirect” url=”https://www.sleep-vip.cn/{R:1}” redirectType=”Permanent” />
</rule>
<rule name=”redirect to HTTPS” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”^OFF$” />
</conditions>
<action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value=”index.html” />
<add value=”index.php” />
<add value=”index.htm” />
</files>
</defaultDocument>
</system.webServer>
</configuration>

回到顶部