我的服务器分配两个主要的网站,说:www.google.com&www.facebook.com(是的,我知道:P)
我希望他们通过https分发。 使用Apache,我在sites-available / enabled中定义了一个包含以下内容的虚拟主机文件:
<VirtualHost *:80> ServerName google.com Redirect / https://www.google.com/ </VirtualHost> <VirtualHost *:80> ServerName facebook.com Redirect / https://www.facebook.com/ </VirtualHost> <VirtualHost *:80> DocumentRoot /srv/www/google/www/ ServerName www.google.com ServerAlias www.facebook.com <Directory ... /> # Google & Facebook points to the same directory (crazy right ?) # Next of the config </VirtualHost> <VirtualHost *:443> SSLEngine On SSLCertificateFile /path/to/google.crt SSLCertificateKeyFile /path/to/google.key DocumentRoot "/srv/www/google/www/" ServerName www.google.com <Directory .../> # Next of the config </VirtualHost> <VirtualHost *:443> SSLEngine On SSLCertificateFile /path/to/facebook.crt SSLCertificateKeyFile /path/to/facebook.key DocumentRoot "/srv/www/google/www/" ServerName www.facebook.com <Directory .../> # Next of the config </VirtualHost>
但是:
基于我的configuration文件,我明白为什么,所以我试图添加:
<VirtualHost *:443> SSLEngine On ServerName facebook.com Redirect / https://www.facebook.com/ </VirtualHost>
但是,我甚至无法通过http / https访问facebook.com和www.facebook.com。
所以我的问题很简单:如何将所有https访问redirect到facebook.com(以及最终的所有子Facebook:facebook.fr,www.facebook.fr等)到www.facebook.com(redirect到www域) HTTPS?
谢谢你的帮助 ! 🙂
这是因为你没有为facebook.comconfiguration虚拟主机,所以Apacheselect了第一个configuration的(www.google.com)。 你在找什么是ServerAliasconfiguration指令。
除非您启用了SNI (在Windows XP上不能在IE上运行),否则您不能在同一个IP上托pipe多个SSL证书。
有时候,你可以使用一个SAN证书(有时也称为UCC),但是你现在正在尝试这样做的方式是行不通的。
要了解的重要一点是,对于HTTPS,在访问Web服务器之前检查服务器SSL证书。 这意味着服务器SSL证书必须包含使用服务器名称指示在该IP地址上要访问的所有域的名称 。 由于某些客户端不支持SNI,因此为不同的HTTPS站点使用不同的IP地址以支持它们并不罕见。
使用上面给出的代码, https://www.facebook.com将无法正常工作,并会给出错误证书的SSL警告。