【问题标题】:Apache redirects all websites to one domain, if there is httpsApache 将所有网站重定向到一个域,如果有 https
【发布时间】:2014-09-30 10:25:09
【问题描述】:

我有一台服务器,其中有很多域,其中一个是 ssl 安全的。

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

在我的 conf 中我使用

<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 条目?
  • 是的,我有,我有ServerName
  • 请发布完整的文件(或更多部分),因为上述信息很少能找出原因。

标签: apache ssl


【解决方案1】:

可能是因为

服务器名继承

最好始终在每个基于名称的名称中明确列出一个 ServerName 虚拟主机。如果 VirtualHost 未指定 ServerName,则服务器 name 将从基本服务器配置继承。如果不 服务器名称是全局指定的,在启动时通过 第一个监听地址的反向DNS解析。在任一情况下, 此继承的服务器名称将影响基于名称的虚拟主机 分辨率,因此最好始终在 每个基于名称的虚拟主机。

Soruce Apache Docs

因此请尝试使用此条目明确定义 ServerName 条目

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-28
    • 2021-11-04
    • 1970-01-01
    • 2012-05-24
    • 1970-01-01
    • 2015-04-17
    相关资源
    最近更新 更多