Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtual Host 2 Without www redirects to virtual host 1

my httpd.conf looks like this:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot /var/www/host1.com
    ServerName   host1.com
    ServerAlias  www.host1.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/host1.com/subdomain
    ServerName   subdomain.host1.com
    ServerAlias  www.subdomain.host1.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/host2.com
    ServerName   host2.com
    ServerAlias  www.host2.com
</VirtualHost>

So, everything works like it should except:

host2.com shows /var/www/host1.com/

whereas

www.host2.com shows /var/www/host2.com/

I'm pretty sure this is an Apache config problem, but I can't figure it out. Any help??

like image 547
Xeno Avatar asked Aug 22 '12 21:08

Xeno


2 Answers

try in this way

DocumentRoot /var/www/host2.com
ServerName   www.host2.com
ServerAlias  *.host2.com
like image 171
sumous Avatar answered Oct 18 '22 07:10

sumous


Try this :

DocumentRoot /var/www/host.com
ServerName   host.com
ServerAlias  *.host.com
like image 3
delirehberi Avatar answered Oct 18 '22 06:10

delirehberi