Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'm setting up a development server and need to apply these basic rules to all virtual hosts on the server in the /var/www/html directory.

AuthType Basic
AuthName "Development Area"
AuthUserFile /var/www/.htpasswd
Require valid-user

I simply tried to put it in my httpd.conf, However apache throws an error when checking the syntax: AuthType not allowed here

share|improve this question
up vote 4 down vote accepted

Authentication always applies to a context; this may be a VirtualHost, a Directory, or a Location.

<Location />
AuthType Basic
AuthName "Development Area"
AuthUserFile /var/www/.htpasswd
Require valid-user
</Location />
share|improve this answer
Many thanks, after some investigation I need this to work only on sites in the /var/www/html directory, is that possible? (also you don't need the / in the closing tag) – Dunhamzzz Nov 16 '12 at 12:26
THanks I've worked it out, just needed to use <Directory> – Dunhamzzz Nov 16 '12 at 12:31
Refer to the documentation for details on how these directives interact with each other: – adaptr Nov 16 '12 at 12:38

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.