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:-

sparky:19m8GEYhMZvMY

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.

link|improve this question
feedback

1 Answer

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
    ...
</Directory>
link|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
1  
Then you should go and look at your apache error log for more .information – Iain Oct 19 '11 at 12:38
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.