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

This documentation says that

Due to the fact that www.example1.com is first in the configuration file, 
it has the highest priority and can be seen as the default or primary server. 
That means that if a request is received that does not match one of the specified 
ServerName directives, it will be served by this first VirtualHost.

How can I disable this, I do not want apache to serve any files if any of the enabled virtual hosts do not match?

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

Just make your first <VirtualHost> one that says no to any request.

<VirtualHost *:80>
    ServerName i-dont-want-your-requests
    Order allow,deny
    Deny from all
</VirtualHost>
share|improve this answer
add comment

To make use of the traffic anyways you could just mock up a page that tells the user that there is nothing to see here and he must have entered the wrong (sub)domain.
Maybe give some possible domains the user might have been looking for or just display some ads.

Would be a shame to let traffic go to waste, not to mention the difference such a page would make in user-friendliness as opposed to a simple "Access Denied" Page.

share|improve this answer
add comment

Your Answer

 
discard

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.