Apache 将所有网站重定向到一个域,如果有 https

标签 apache ssl

我有一台服务器,其中有很多域,其中一个是受 SSL 保护的。

如果我将任何其他域与 https://一起使用,它会显示 ssl 安全站点的内容。

在我的 session 中我使用

<VirtualHost *:443>
    ServerName www.example.com

    DocumentRoot /home/domains/example.com/web/public/www/

    SSLEngine on
    SSLCertificateFile /home/domains/example.com/web/ssl/www.example.com.crt
    SSLCertificateKeyFile /home/domains/example.com/web/ssl/www.example.com.key
    SSLCertificateChainFile /home/domains/example.com/web/ssl/www.example.com.ca
#   SSLCACertificateFile /home/domains/example.com/web/ssl/www.example.com.ca

    ErrorLog /home/domains/example.com/web/log/error.log
    CustomLog /home/domains/example.com/web/log/access.log combined
</VirtualHost>

我发现可能是问题所在,但我没有找到任何解决方法。

有人可以告诉我如何解决它,或者指导我查看适当的文档吗?

谢谢。

最佳答案

可能是因为

ServerName inheritance

It is best to always explicitly list a ServerName in every name-based virtual host. If a VirtualHost doesn't specify a ServerName, a server name will be inherited from the base server configuration. If no server name was specified globally, one is detected at startup through reverse DNS resolution of the first listening address. In either case, this inherited server name will influence name-based virtual host resolution, so it is best to always explicitly list a ServerName in every name-based virtual host.

Soruce Apache Docs

因此尝试使用此条目显式定义 ServerName 条目

<VirtualHost *:443>
    ServerName www.example.com
    ServerAlias example.com 
    DocumentRoot /www/domain
</VirtualHost>

关于Apache 将所有网站重定向到一个域,如果有 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26118474/

相关文章:

python - 我怎样才能制作一个 Python 包来为带有 Flask 的网站提供服务以与 Apache 一起工作?

java - Apache Builder - 将工件提取到项目根目录

Apache mod_rewrite Restful api

apache - WAMP 服务器端包括不适用于 .shtml 文件

delphi - 如何使用 Delphi 从 Windows 证书存储中读取 SSL 证书

apache - htaccess 重定向的奇怪行为

android - 来自 Android 应用程序的 HTTPS

python - ./manage.py runserver 使用 https

laravel - Firefox 强制开发域使用 SSL 和 Chrome

java - 获取在 HttpsURLConnection 中使用的 SSL 版本 - Java