1. 程式人生 > >在CentOS 7 1804 中 配置 Apache HTTP Server 將 http 自動跳轉之 https

在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配置檔案:
    [[email protected] ~]# 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