Apache下配置Http自动跳转Https

配置详情:
<VirtualHost *:80>
    ServerName domain name
    DocumentRoot /dir    
    <Directory "/dir">      
        Options -Indexes +FollowSymlinks      
        Require all granted  
        Require host ip   
    </Directory>
    #这里开始配置自动跳转https
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]
</VirtualHost>
 
配置成功之后,使用http访问时会自动跳转至https
 
注意:在apache跳转的话会有个问题
在后续访问的过程中,可能会post提交数据
如果提交至http会自动跳转至https,那么这个时候这种方式会出现无法接收到post数据的情况
其实是跳转后已经转换为get模式了,也没有带上post的数据,所以开发过程中一定要注意,必须使用https提交post数据
posted @ 2020-04-30 14:18  Vergil-T  阅读(561)  评论(0)    收藏  举报