主要看一下C:/wamp64/bin/apache/apache2.4.37/conf/extra下的http-ssl.conf与httpd-vhosts.conf文件的配置
http-ssl.conf:
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "C:\wamp64\www\b2b\admin\img"
ServerName img.ygoffice.com:443
ServerAdmin admin@example.com
ErrorLog "${INSTALL_DIR}/bin/apache/apache2.4.37/logs/img_error.log"
TransferLog "${INSTALL_DIR}/bin/apache/apache2.4.37/logs/img_access.log"
SSLEngine on
SSLCertificateFile "${INSTALL_DIR}/bin/apache/apache2.4.37/conf/ssh/img/1535611_img.ygoffice.com_public.crt"
SSLCertificateKeyFile "${INSTALL_DIR}/bin/apache/apache2.4.37/conf/ssh/img/1535611_img.ygoffice.com.key"
SSLCertificateChainFile "${INSTALL_DIR}/bin/apache/apache2.4.37/conf/ssh/img/1535611_img.ygoffice.com_chain.crt"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "${INSTALL_DIR}/bin/apache/apache2.4.37/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
<Directory "C:\wamp64\www\b2b\admin\img">
AllowOverride All
Require local
Require all granted
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "${INSTALL_DIR}/bin/apache/apache2.4.37/logs/img_ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
http-ssl.conf下配置443端口(https),httpd-vhosts.conf配置80端口
<VirtualHost *:80>
ServerName img.ygoffice.com
ServerAlias img.ygoffice.com
DocumentRoot "C:\wamp64\www\b2b\admin\img"
#HTTP_TO_HTTPS_START
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}$1 [L,R=301]
</IfModule>
#HTTP_TO_HTTPS_END
<Directory "C:\wamp64\www\b2b\admin\img">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require all granted
</Directory>
</VirtualHost>
当然还要配置一下hosts文件。
最后:在配置过程中,可能会遇到apache重启不了。在C:/wamp64/bin/apache/apache2.4.37/bin目录下执行命令:
httpd -t
即可查看报错信息