均哥分享

伪静态方式强制http跳转https

2020-05-19 19:23:52 admin 39

1.Apache上的.htaccess实现强制https跳转访问:文件名为.htaccess

RewriteEngine On

RewriteBase /

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]



2.IIS中:命名为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>



   


       


                           


               


                   


                   


                       


                   


                   


               


           


       


   




首页
分享
日志
联系