HTTPS跳转HTTP代码 IIS伪静态强制HTTP访问

发布时间:2018/12/4 8:53:03 打印 字号:

该代码实现:https://www.gworg.com/  跳转到:http://www.gworg.com/ 

1、适用于HTTPS网站由于程序不支持,放弃HTTPS找回HTTPS的余留流量。 

2、搜索引擎收录HTTPS地址,但HTTPS停止后要求HTTPS跳转到HTTP。

3、百度站长用户:HTTPS认证后HTTPS退场设置。

注:由于是HTTPS跳转到HTTP代码!在设置跳转前提需要确保HTTPS是可以访问的条件下!否则跳转将失败!


Windows服务器IIS环境,网站根目录创建:web.config(前提IIS服务器已安装“URL重写”已拥有的无需安装)

“URL重写” 模块下载地址

微软下载地址(64位):http://www.microsoft.com/zh-cn/download/details.aspx?id=7435

微软下载地址(32位):http://www.microsoft.com/zh-cn/download/details.aspx?id=5747

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Gworg HTTPS跳转HTTP" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{SERVER_PORT}" pattern="443" ignoreCase="false" />
                    </conditions>
                    <action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


伪静态跳转:网站根目录新建 .htaccess(支持Apache环境)

RewriteCond %{SERVER_PORT} 443
RewriteRule (.*) http://%{SERVER_NAME}/$1 [R=301,L]


Nginx跳转方式:也适用于宝塔BT控制面板环境(Linux与Windows系统):

if ($server_port ~ "443"){
	set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
	rewrite /(.*) http://$server_name/$1 permanent;
}

宝塔面板.png