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 tried to implement htaccess password protection for a directory in my localhost.

My htaccess file is situated in /home/Server/Dev. The directory I want to protect is /Dev/. My .htaccess file has the following contents:-

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /home/admin/.htpasswd 
AuthGroupFile /dev/null 
require valid-user

My .htpasswd file is situated in /home/admin/.htpasswd and has the following content:-


But when I try accessing http://localhost/Dev/, password is not asked and the url is directly accessible. Can anyone please point out what I'm doing wrong.

share|improve this question

This will most likely be because you have an AllowOverride statement that is disallowing access to .htaccess files. You will need to configure as a minimum

AllowOverride AuthConfig 

within a <Directory> block for /home/Server/Dev

<Directory /home/Server/Dev >
    AllowOverride AuthConfig
share|improve this answer
I added AllowOverride AuthConfig to 000-default' within a <Directory> block for /home/Server/Dev`. Now the username-password window is shown, but no matter what I enter, a 500 internal server error page is shown when i click login. – Sparky Oct 19 '11 at 12:06
Then you should go and look at your apache error log for more .information – Iain Oct 19 '11 at 12:38
Whoever finds this online, don't forget to add ErrorDocument 401 "Authorisation Required" because otherwise it will throw you into an endless loop if you don't get the password right – The Sexiest Man in Jamaica Jun 1 at 8:37

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.