Forum Topic: 500 error when password protecting a directory

Forum: .htaccess Forum : Security • Posted by Jan Koch • Updated:

When I copy the code the following code from the book into a blank .htaccess file, I get a 500 error:

<IfModule mod_authn_file.c>
      AuthName "Username and password required"
      AuthType Basic
      AuthUserFile /my/own/path/.htpasswd
      <Limit GET POST>
            Require valid-user
      </Limit>
</IfModule>

If I just use the following code, it's working:

AuthType basic
AuthName "Username and password required"
AuthUserFile /my/own/path/.password
Require valid-user

What is the difference?

3 Replies to “500 error when password protecting a directory”

Jeff Starr
Posted by Jeff Starr

Hi Jan,

It looks like maybe a required module is not install/active.. are you able to locate the associated error message in your server log(s)? That would help us pinpoint the exact issue.

Posted by Jan Koch •

Hey Jeff,

unfortunately I don't have access to the server logs, the web host won't give them to me.

It's a client site that I had to protect.

However, since the code without

<IfModule mod_authn_file.c>
...
</IfModule>

is working fine, I assume that will do the job as well.

Thanks for your fast reply!

Jeff Starr
Posted by Jeff Starr

Alright that works! Best of luck with your project :)