Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CentOS LAMP server. It has several vhosts configured. If I navigate to:  (server IP)

Apache displays one of the sites. How can I configure Apache to show nothing or perhaps a 403 Forbidden? If it could show a forbidden before checking for malformed requests that would be even better.

share|improve this question
up vote 4 down vote accepted

The first vhost that Apache picks up from your configuration is the default one picked when the name that the client sends doesn't match any configured vhost, so you'll have to make a vhost that sends 403 errors and ensure that it's picked up first in the httpd config.

share|improve this answer
Will this show the 403 even if it's a malformed request where a 400 would normally be served? Also what's the syntax in the vhost directive to issue the 403? – ServerBloke Mar 30 '12 at 19:23
Order Allow,Deny, Deny from all. Put it in a <Location /> block in the default (first) vhost. – Shane Madden Mar 30 '12 at 19:51
Thanks, the 403 can also be done by removing the DocumentRoot in the first vhost. – ServerBloke Apr 2 '12 at 8:30

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.