rockyraw
rockyraw

Reputation: 1145

.htaccess Password protection keeps asking for password over and over

I've placed this code in the .htaccess file of the folder I want to protect:

AuthName "restricted area"
AuthType Basic
AuthUserFile /home/#/#/#/#/#/.htpasswd
require valid-user

In the same folder, I placed this .htpasswd:

my:pass

When I go to the URL of the protected folder, the browser keeps asking me for a password over and over, even though I'm typing the correct one.

I know that the root directory mentioned in AuthUserFile is ok because I've found it out with:

<?php
    $dir = dirname(__FILE__);
    echo "<p>Full path to a .htpasswd file in this dir: " . 
        $dir . "/.htpasswd" . "</p>";
?>

Where's the problem?

Upvotes: 8

Views: 13337

Answers (3)

thewarpreactor
thewarpreactor

Reputation: 31

the problem, so i found for my website, is that the htpasswd file path is not the same as the path provided in the htaccess. I spent weeks trying to find where the problem was, but although you create usernames and passes using the htpasswrd the file is not communicating with the secure folder. You will need to find out why. maybe a spelling mistake or as in my case, the htpasswd was being saved in a completely different folder, and i had 2 htpasswrd in different folders. the two need to communicate htacccess and htpasswrd, hope this saves you time I figured it out after weeks of sleepless nights.

Upvotes: 3

kojow7
kojow7

Reputation: 11424

I have just come across this problem. After trying to figure it out for the last couple of days I have found out the source of the problem:

This prompt gets triggered when using AuthType Basic and whenever a 401 message is sent from the website.

Is it possible that you had a 401 HTTP status code message being sent from the server at each request? You can check your developer console to find out.

Upvotes: 0

Mark
Mark

Reputation: 135

Just add "user" in between require valid-user

For example:

Require user markpanado

But not:

Require markpanado

Upvotes: 4

Related Questions