Http打开与https不同的apache站点

我已经设置httpredirect到https在我启用的网站cloud.conf所以最近我启用站点000-default使用sudo a2ensite 000-default现在这启用了我的000-default站点,它打开预期的文档根没有httpredirect到https因为我没有任何在000默认。

但后来当我启用了网站云端sudo a2ensite cloud它确实启用了我的https网站,打开预期的网站云,但是如果我打开http站点,它既不会自动redirect到https,也可以在http模式下打开000默认网站。

首先,当我启用网站为什么它仍然在http模式下打开旧网站,而不是redirect?

UPDATE

 $ apachectl -S AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: *:80 is a NameVirtualHost default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost 192.168.1.3 (/etc/apache2/sites-enabled/cloud.conf:1) *:443 is a NameVirtualHost default server 192.168.1.3 (/etc/apache2/sites-enabled/cloud.conf:10) port 443 namevhost 192.168.1.3 (/etc/apache2/sites-enabled/cloud.conf:10) port 443 namevhost 192.168.1.3 (/etc/apache2/sites-enabled/cloud.conf:30) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex watchdog-callback: using_defaults Mutex rewrite-map: using_defaults Mutex ssl-stapling: using_defaults Mutex proxy: using_defaults Mutex ssl-cache: using_defaults Mutex default: dir="/var/lock/apache2" mechanism=fcntl Mutex mpm-accept: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 not_used Group: name="www-data" id=33 not_used 

现在我想知道如何在端口80启用2个站点

所以,这是你的问题。 您有两个http虚拟主机定义一个ServerName 127.0.0.1和一个192.168.1.3 。 这意味着在地址栏中任何不使用192.168.1.3的HTTP请求都将login到第一个虚拟主机(名称为127.0.0.1)。

注意是没有关系,这看起来应该只是本地主机,这只是它的名字。 这是一个*:80虚拟主机,因此可以在机器的任何networking接口上使用。

/etc/apache2/sites-enabled/cloud.conf两个具有相同ServerName (192.168.1.30)的HTTPS虚拟主机。 只有第一个,默认,会收到请求。

基于虚拟主机的命名方式的工作原理是,对于任何IP /端口组合,Apache将尝试将Host HTTP头与ServerNameServerAlias指令进行匹配。 第一个匹配的虚拟主机收到请求。 如果找不到匹配,则列出的第一个接收请求。

Host HTTP头缺省为模式(即http://或https://正常)和URIpath(从下一个'/'之后的位)之间的URL部分。