你的位置:首页 > 互联网IT

http转https,http跳转https,http自动跳转https,http变https,IIS7 http自动跳转到https(通过编辑Web.config实现)

系统:Windows

功能:http跳转https

相同文章:https://m.012.ooo/?id=257

用法:Web.config 放入网站根目录

1.下载安装URL重写模块:Microsoft URL Rewrite Module


32位:http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi


64位:http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi


2.SSL设置不要勾选(很重要)

QQ截图20220327234452.jpg http转https,http跳转https,http自动跳转https,http变https,IIS7 http自动跳转到https(通过编辑Web.config实现) 互联网IT

3.Web.config添加

第一种:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

   <rewrite>

     <rules>

       <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>


第二种:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

    <system.webServer>

        <rewrite>

            <rules>

                <rule name="HTTP to HTTPS redirect" stopProcessing="true">

                    <match url="(.*)" />

                    <conditions>

                        <add input="{HTTPS}" pattern="^OFF$" />

                        <add input="{HTTPS_HOST}" pattern="^(localhost)" negate="true" />

                    </conditions>

                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />

                </rule>

            </rules>

        </rewrite>

    </system.webServer>

</configuration>


文章转载:https://www.cnblogs.com/xiaohi/p/8038042.html

本文摘自:https://www.cnblogs.com/wxbug/p/7054972.html


  • 发表评论
  • 查看评论
【暂无评论!】

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。