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.

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
add comment

1 Answer

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: httpd.apache.org/docs/2.2/sections.html#file-and-web –  adaptr Nov 16 '12 at 12:38
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.