1. 程式人生 > >https----------如何在phpstudy環境下配置apache的https訪問以及訪問http自動跳轉成https

https----------如何在phpstudy環境下配置apache的https訪問以及訪問http自動跳轉成https

寫入 rom virtual write rule 找到 engine rul str

1、首先在 httpd.conf裏面修改幾個地方

  找到 #LoadModule ssl_module modules/mod_ssl.so 去掉前面的#

  Include conf/vhosts.conf 在這一行下面增加一行 Include conf/vhosts_ssl.conf 然後去conf文件夾裏面創建vhosts_ssl.conf

2、在vhosts_ssl.conf裏面寫入

  Listen 443
  SSLStrictSNIVHostCheck off
  SSLCipherSuite AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL


  SSLProtocol all -SSLv2 -SSLv3
  <VirtualHost *:443>
  DocumentRoot "D:\phpStudy\zhifu"
  ServerName www.ceshi.com
  ServerAlias ceshi.com
  <Directory "D:\phpStudy\zhifu">
  Options FollowSymLinks ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all

  Require all granted
  </Directory>
  SSLEngine on
  SSLCertificateFile "D:\phpStudy\Apache\conf\zheng\2_www.ceshi.com.crt"
  SSLCertificateKeyFile "D:\phpStudy\Apache\conf\zheng\3_www.ceshi.com.key"
  SSLCertificateChainFile "D:\phpStudy\Apache\conf\zheng\1_root_bundle.crt"

  </VirtualHost>

3、將證書上傳到,上面配置寫的對應的路徑裏面

4、在vhosts.conf裏面配置自動跳轉

  <VirtualHost *:80>
  DocumentRoot "D:\phpStudy\zhifu"
  ServerName www.ceshi.com
  ServerAlias ceshi.com
  RewriteEngine On
 RewriteRule (.*) https://%{SERVER_NAME}$1 [R]
   <Directory "D:\phpStudy\zhifu">
   Options FollowSymLinks ExecCGI
   AllowOverride All
   Order allow,deny
   Allow from all
   Require all granted
   </Directory>
  </VirtualHost>

5、以上要註意,我寫的ceshi的地方,都要改成自己的

https----------如何在phpstudy環境下配置apache的https訪問以及訪問http自動跳轉成https