我正在使用apache 2.4
和php 7.3
,我已将2个域上载到服务器,其中一个我想通过普通HTTP加载,另一个想通过HTTPS加载,因此我安装了证书-让我们加密SSL的漫游器。
假设domainA用于HTTPS,domainB用于HTTP
domainA
可以通过https很好地加载。
domainB
试图加载https,即使我手动输入http,它也会重定向,浏览器会阻止证书是错误的,因为它来自domainA 。 (虚拟主机看上去正确设置)
然后我测试了加载服务器的特定IP地址,甚至IP地址也试图通过https加载,这没有任何意义。
虚拟主机文件:
<VirtualHost *:80>
DocumentRoot /var/www/html/production/domainA.com/public
ServerName www.domainA.com
RewriteEngine On
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/html/production/domainA.com/public
ServerName domainA.com
ServerAlias www.domainA.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1$1 [L,R=301]
SSLEngine on
SSLCertificateKeyFile /etc/letsencrypt/live/domainA.com/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/domainA.com/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/domainA.com/fullchain.pem
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/production/domainB.com/public
ServerName www.domainB.com
</VirtualHost>
我什至没有在域B上加载SSL ,不确定我丢失了什么,或者应该看哪里?我担心的是,实际的服务器IP地址正在执行相同的操作。
更新:看起来像conf文件中首先加载的主机是服务器默认的样子,将domainB移到首先允许非http域现在加载。