设置 Apache 2.4 和 Wordpress 后,我收到以下 SSL 错误消息:
$ wget "https://example.com"
Resolving example.com (example.com)... 192.168.15.5
Connecting to example.com (example.com)|192.168.15.5|:443... connected.
ERROR: no certificate subject alternative name matches
requested host name ‘ example.com’.
To connect to example.com insecurely, use `--no-check-certificate'.
为了使域名与我的 SSL 证书 ( www.example.com
) 匹配,我尝试调整站点配置以将https://example.com重定向到https://www.example.com。但它不起作用:http-to-https 重定向功能如预期,但裸域到 www-domain 没有。
这是我的站点配置:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://www.example.com/
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName www.example.com
Protocols h2 http/1.1
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
DirectoryIndex index.php
RewriteEngine on #### Doesn’t work at all ####
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^/(.*) https://www.example.com/$1 [L,R=301]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSL with Letsencrypt Include /etc/letsencrypt/options-ssl-apache.conf
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
</VirtualHost>
</IfModule>
该站点本身运行良好,并且.htaccess
仅包含由 Wordpress 创建的行。
任何输入表示赞赏。
您仍然需要有效的证书
http://example.com
。重定向发生在建立有效的 TLS 连接之后。在 SAN 字段中
example.com
获取证书。www.example.com