首先移步到你的配置文件目录,证书从阿里云购买

apache\conf\vhost

多站点配置请不要在 httpd.conf 上做文章!!!

打开 xxxxx.conf 对应的域名配置

里面原有的80端口内容不要改动,下面新增

<VirtualHost *:443>

    DocumentRoot "D:\wwwroot\www_abc_com"
    ServerName www.abc.com
    ServerAlias abc.com www.abc.com

    SSLEngine on
    SSLCertificateFile D:\ssl\www.abc.com\xxx.crt
    SSLCertificateKeyFile D:\ssl\www.abc.com\xxx.key
    SSLCertificateChainFile D:\ssl\www.abc.com\xxx.crt

    ErrorDocument 403 /403.html
    ErrorDocument 404 /404.html
    ErrorDocument 502 /502.html

</VirtualHost>

SSLCertificateFile 是指证书公钥
SSLCertificateKeyFile 是指证书私钥
SSLCertificateChainFile 是指根证书

然后复制 80 端口里面的除下面内容外的一些配置:

<VirtualHost *:80>
    DocumentRoot "D:\wwwroot\zyyspwlpt.com"
    ServerName zyyspwlpt.com
    ServerAlias zyyspwlpt.com www.zyyspwlpt.com
    
    ErrorDocument 403 /403.html
    ErrorDocument 404 /404.html
    ErrorDocument 502 /502.html

复制到 443 端口配置文档里面

需要强制HTTPS的话,可以使用 .htaccess 内容如下:

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>

重启 apache

标签: ssl, apache, window

添加新评论