domain2.com redirects to domain1.com in Apache

Posted by Dmitry Mikhaylov on Server Fault See other posts from Server Fault or by Dmitry Mikhaylov
Published on 2012-09-08T15:52:09Z Indexed on 2012/09/16 15:40 UTC
Read the original article Hit count: 412

Filed under:

I created new virtual host, but when I try to request it, Apache redirects me to another virtual host. What could cause this problem?

<VirtualHost XXX.XXX.XXX.XXX:80 >
    ServerName domain1.com
    AddDefaultCharset utf-8
    CustomLog /var/www/httpd-logs/domain1.com.access.log combined
    DocumentRoot /home/user/www/domain1.com
    ErrorLog /var/www/httpd-logs/domain1.com.error.log
    ServerAdmin [email protected]
    ServerAlias www.domain1.com
    SuexecUserGroup user user
    AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
    AddType application/x-httpd-php-source .phps
    php_admin_value open_basedir "/home/user:."
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f [email protected]"
    php_admin_value upload_tmp_dir "/home/user/mod-tmp"
    php_admin_value session.save_path "/home/user/mod-tmp"
    ScriptAlias /cgi-bin/ /home/user/www/domain1.com/cgi-bin/
</VirtualHost>

<VirtualHost XXX.XXX.XXX.XXX:80 >
    ServerName domain2.com
    CustomLog /dev/null combined
    DocumentRoot /home/user/www/domain2.com
    ErrorLog /dev/null
    ServerAdmin [email protected]
    ServerAlias www.domain2.com
    SuexecUserGroup user user
    AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
    AddType application/x-httpd-php-source .phps
    php_admin_value open_basedir "/home/user:."
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f [email protected]"
    php_admin_value upload_tmp_dir "/home/user/mod-tmp"
    php_admin_value session.save_path "/home/user/mod-tmp"
</VirtualHost>

"apache2ctl -S" output:

VirtualHost configuration:
XXX.XXX.XXX.XXX:80 is a NameVirtualHost
         default server domain1.com (/etc/apache2/apache2.conf:266)
         port 80 namevhost domain1.com (/etc/apache2/apache2.conf:266)
         port 80 namevhost domain2.com (/etc/apache2/apache2.conf:284)
XXX.XXX.XXX.XXX:443      is a NameVirtualHost
         default server domain1.com (/etc/apache2/apache2.conf:246)
         port 443 namevhost domain1.com (/etc/apache2/apache2.conf:246)
wildcard NameVirtualHosts and _default_ servers:
*:443                  is a NameVirtualHost
         default server www.example.com (/etc/apache2/apache2.conf:239)
         port 443 namevhost www.example.com (/etc/apache2/apache2.conf:239)
*:80                   is a NameVirtualHost
         default server domain1.com (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost domain1.com (/etc/apache2/sites-enabled/000-default:1)

© Server Fault or respective owner

Related posts about apache2