Apache2奇怪的重定向。 (默认网站覆盖其他网站)

时间:2014-04-18 11:30:30

标签: apache ubuntu

我刚刚从Amazon EC2转移到另一个VPS,在它们上面运行Ubuntu 12.04。 但是现在我得到了一些非常奇怪的重定向。

无论我使用http(端口80)访问哪个域名,我最终都在同一个域中。我没有重定向到这个域。

http://domain1.com工作正常,但http://domain2.com重定向到http://domain1.com 即使我刚进入IP地址,我也会获得domain1.com。似乎Apache2无法解析请求的来源名称。

如果我在https://domain2.com处通过SSL访问,则加载就好了,没有重定向。

我想我删除了" default.conf"在安装apache2之后立即在"基于站点的"文件夹中存档。这有什么影响吗?

以下是apache2ctl -S输出:

AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/ports.conf:5
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:1)
         port 80 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:1)
         port 80 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:1)
                 alias www.domain2.com
*:443                  is a NameVirtualHost
         default server domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:10)
         port 443 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:10)
         port 443 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:9)
                 alias www.domain2.com
         port 443 namevhost domain3.com (/etc/apache2/sites-enabled/domain3.com.conf:2)
                 alias www.domain3.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: 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

这是我的domain1.com.conf(完全类似于domain2.com.conf,除了域名):

<VirtualHost *:80>

    ServerName domain1.com
    ServerAdmin my@email.com
    DocumentRoot /var/www/domain1.com

</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.

    ServerName domain1.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/domain1.com

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/domain1.com/domain1.com.crt
    SSLCertificateKeyFile /etc/apache2/ssl/domain1.com/domain1.com.key
    SSLCertificateChainFile /etc/apache2/ssl/domain1.com/sub.class1.server.ca.pem

    # Security settings for SSL
    SSLProtocol ALL -SSLv2 -SSLv3
    SSLHonorCipherOrder On
    SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

2 个答案:

答案 0 :(得分:2)

/ etc / apache / sites-available中的default.conf并不特别 - 但是当它被列为/ etc / apache / sites-enabled中的第一个文件时(通常为00-default.conf,所以它是首先在列表中)然后它将是默认值。如果不存在,那么首先列出的任何其他内容(如domain1.conf)将是默认站点,如果该URL未被其他文件中列出的任何其他vhost捕获,则将显示该站点。

答案 1 :(得分:0)

https://my.ionos.com/settings-general

勾选这个选项Set Hosting as your homepage

然后重定向到默认站点不会发生。