在CentOS 7 1804 中 配置 Apache HTTP Server 将 http 自动跳转之 https

相关链接:

在CentOS 7 1804 中 安装 Apache HTTP Server 并 配置 腾讯云 SSL

在CentOS 7 1804 中 安装 Apache HTTP Server 并 配置 阿里云 SSL

在CentOS 1804 中的 Tomcat 9 设置 SSL( https ) 加密 (多域名加密,阿里云 SSL+ 腾讯云 SSL)

在CentOS 1804 中设置 Apache Tomcat 9.0.12 开机自启

在tomcat中设置http自动跳转https


  1. 编辑httpd配置文件:
    [root@CentOS-x86-64-DVD-1804-Desktop ~]# vim /etc/httpd/conf/httpd.conf
    
  2. 修改说明:
    找到下列内容:
    <Directory "/var/www">
        AllowOverride None
        # Allow open access:
        Require all granted
    </Directory>
    
    修改为:
    <Directory "/var/www">
        AllowOverride None
        # Allow open access:
        Require all granted
    
    RewriteEngine on
    RewriteCond "%{SERVER_PORT}" !^443$
    RewriteRule "^/?(.*)" "https://%{SERVER_NAME}%{REQUEST_URI}" [L,R,NE]
    
    </Directory>
    
     
    1. RewriteEngine on:
      开启重写
    2. RewriteCond "%{SERVER_PORT}" !^443$:
      端口不是443(%{SERVER_PORT}:访问的端口)
    3. RewriteRule "^/?(.*)" "https://%{SERVER_NAME}%{REQUEST_URI}" [L,R,NE]:
      重定向到https(%{SERVER_NAME}%:访问的域名,%{REQUEST_URI}:请求的URI)

      参考文档:http://httpd.apache.org/docs/2.4/pt-br/rewrite/remapping.html

相关链接:

在CentOS 7 1804 中 安装 Apache HTTP Server 并 配置 腾讯云 SSL

在CentOS 7 1804 中 安装 Apache HTTP Server 并 配置 阿里云 SSL

在CentOS 1804 中的 Tomcat 9 设置 SSL( https ) 加密 (多域名加密,阿里云 SSL+ 腾讯云 SSL)

在CentOS 1804 中设置 Apache Tomcat 9.0.12 开机自启

在tomcat中设置http自动跳转https

猜你喜欢

转载自blog.csdn.net/qq_32596527/article/details/83096128