Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am attempting to set up htaccess to restrict access to a particular folder. I currently have as follows:

Htaccess:

AuthType Basic
AuthName "Restricted area"
AuthUserFile /home3/user/public_html/.htpasswd
require valid-user

ErrorDocument 404 "Error"
ErrorDocument 401 "Error"
ErrorDocument 403 "Error"

htpasswd:

Guest:GuestPassword

Using this method I will either have a 500 server error returned, OR it will loop and continuously prompt me for authentication.

Any help is appreciated!

ALSO: I used showphp() to get the Document root. So AuthUserFile path should be correct.

Thanks!

share|improve this question
1  
That seems... a weird .htpasswd to me.. Usually an encrypted password is added by running htpasswd /path/to/.htpasswd username, have you tried that? –  Wrikken Jun 3 at 22:04
 
Ive seen reference to that but I have not done that yet. How would you go about doing that? –  user2138152 Jun 3 at 22:13
 
You mean by writing to the file rather then editing by hand correct? –  user2138152 Jun 3 at 22:27
 
You also shouldn't have you .htapassword file in your web directory. –  Mike Brant Jun 3 at 22:40
 
Oops, yes I meant for it to be at the root, not the root public folder. –  user2138152 Jun 3 at 23:40
show 2 more comments

1 Answer

The infinite loop asking for your password is what you want to see. That means you typed in your password wrong. The Internal Server 500 Error means you have another issue in your code. The reason your username and password aren't working is because your server expects the password to be hashed.

Change your .htpasswd file to:

Guest:$apr1$u5E5vgOR$6rPNEYkeaF5IVE4c3FyKM0

(The password is GuestPassword)

share|improve this answer
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.