3

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!

7
  • 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? Commented Jun 3, 2013 at 22:04
  • Ive seen reference to that but I have not done that yet. How would you go about doing that? Commented Jun 3, 2013 at 22:13
  • You mean by writing to the file rather then editing by hand correct? Commented Jun 3, 2013 at 22:27
  • You also shouldn't have you .htapassword file in your web directory. Commented Jun 3, 2013 at 22:40
  • Oops, yes I meant for it to be at the root, not the root public folder. Commented Jun 3, 2013 at 23:40

1 Answer 1

6

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.