htaccess gives 500 - Internal Server Error

no0ne picture no0ne · Mar 24, 2013 · Viewed 18.2k times · Source

I am protecting a html file with htaccess and htpasswd. When I try accessing it, after putting both user and password, instead of loading the "index.html" file I get a "500 - Internal Server Error"

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

Any suggestions? Maybe something with the hosting service?

Answer

kronn picture kronn · Mar 24, 2013

First of all, consult the error-log (usually located in /var/log/apache2/error.log) to see the exact cause of the error.

If you do not have access to it, check the following:

  • is this technique supported by the server? (ask your provider or admin)
  • is AuthUserFile correct? It seems to be missing a slash and the directory is unusual. I would have suspected something like AuthUserFile /home/webuser/sitefolder/.htpasswd.
  • change the group-file to AuthGroupFile None instead of pointing apache to read /dev/null. Think of /dev/null as a bottom-less trashcan. It's not easy to get anything from there and might be a reason for the server to fail trying.
  • change the case of your require to Require valid-user. It needs to be a capital R.

To sum up:

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /home/webuser/sitefolder/.htpasswd 
AuthGroupFile None
Require valid-user

For further info, I recommend http://httpd.apache.org/docs/.