I have 2 sites defined in my Apache2. Each one has a servername.

For example:

Server 1 (first in sites-enabled) responds to www.example.com
Server 2 (second in sites-enabled) responds to www.example2.com

Ok, the problem is when I type the server IP in the URL, the first server responds.

How could I limit the response to only specifying its servername? I would like to block the IP calls.

If that is not possible, I would like the second server to respond, not the first. I cannot change the order because there are aliases defined in the second server that would override the first server config.

link|improve this question

75% accept rate
feedback

2 Answers

Try using apache's default host option http://httpd.apache.org/docs/2.2/vhosts/examples.html#default

link|improve this answer
It is not working. It seems the first server is catching all petitions containing the IP. – David May 25 '10 at 10:32
feedback
up vote 1 down vote accepted

Finally, I have the solution.

I just created a new virtual host, with the ServerName set to the server IP address.

Now every request to the server IP will be catched by the new virtual host.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.