ASP网站:强制HTTPS设置,伪静态规则301跳转规则写法

对于ASP网站,使用宝塔设置强制HTTPS时,提示:面板无法自动给Aspx/Asp程序强制HTTPS,请将以下代码添加到网站目录下的【web.config】文件中,添加完毕后重启IIS生效

 

 

 复制好规则,根据提示,前往网站根目录,找到文件 web.config,在rules标签内,添加规则,保存即可。

 

全部规则:

<?xml version="1.0" ?>
<configuration>
    <location path="." allowOverride="false" inheritInChildApplications="false">
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="http_toHttps" stopProcessing="true">
                        <match url="(.*)"/>
                        <conditions>
                            <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
                        </conditions>
                        <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}"/>
                    </rule>
                </rules>
            </rewrite>
            <defaultDocument configSource="web_config\default.config"/>
            <httpErrors configSource="web_config\httpErrors.config"/>
            <handlers configSource="web_config\php.config"/>
        </system.webServer>
    </location>
</configuration>

 

注意,保存后,访问域名如 http://www.abc.com,如果没有跳转到https://www.abc.com,可以进行如下操作:

1.清空浏览器缓存(CTR+F5);

2.重启服务器

 

posted @ 2022-03-14 14:40  coderjim  阅读(685)  评论(0编辑  收藏  举报

更多知识请点击——

www.7017online.xyz