0

I've configured two Virtual Hosts using a single IP and following the documentation. Here the conf:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server host1.example.com (/etc/httpd/conf/httpd.conf:1019)
         port 80 namevhost host1.example.com (/etc/httpd/conf/httpd.conf:1019)
         port 80 namevhost host2.example.com (/etc/httpd/conf/httpd.conf:1024)

If I point my browser to host1.example.com or host2.example.com, I can see the correct corresponding page. If I point to the server name server.example.com, I see the host1.example.com index.html, and not the index.html in the corresponding DocumentRoot (/var/www/html). Is this the correct behaviour?

2
  • show us your actual apache configuration, I'm not sure what you have given us. Commented Feb 9, 2014 at 15:28
  • That was the output of httpd -S. Commented Feb 11, 2014 at 14:40

1 Answer 1

1

Yes, the behavior changes when you enable virtual hosts from serving the global DocumentRoot directory to serve the first defined virtual host.

You should set a first virtual host (that appears in your configuration) to serve /var/www/html and then one for host1 and another for host2.

1
  • Makes sense. And what if I would not use the DocumentRoot /var/www/html directory? Should I comment it in the httpd.conf? Commented Feb 11, 2014 at 14:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.