سؤال

I have the following code to protect my application:

.htaccess:

AuthType Basic
AuthName "My Protected Area"
AuthUserFile .htpasswd
Require valid-user

.htpasswd:

username:$apr1$Am/5PMEt$JofEYwKBM8rhEnsoLndir/

The .htpasswd file is in the same directory as the .htaccess file.

It does ask me for authentication, but then gives me a 500 server error. I just used this tool, so I am wondering what I might be doing wrong?

Thanks!

هل كانت مفيدة؟

المحلول

Try changing the .htpasswd to use the full path starting from / and using this tool instead: http://www.askapache.com/online-tools/htpasswd-generator/

AuthType Basic
AuthName "My Protected Area"
AuthUserFile /var/www/public_html/full/path/to/.htpasswd
Require valid-user
Satisfy All

Otherwise it sounds like the error is being caused by some other issue. Likely 1 of 2:

  1. The permissions on the .htaccess or .htpasswd file are bad
  2. There is some other error like a rewrite or something in a .htaccess or php error

You need to cause this error to happen again, and then view your /var/log/httpd/error_log file (or named something similar) which will tell you the reason for the 500 error.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top