Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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

share|improve this answer
It is not working. It seems the first server is catching all petitions containing the IP. –  David Morales May 25 '10 at 10:32
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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