Create .htaccess and .htpasswd

1

I have a folder on a server where I have to add a password. I have researched and I have seen that there is a file .htpasswd . The problem is that it does not work for me.

.htaccess

AuthName "Directorio privado"
AuthType Basic
AuthUserFile /www/test/app/app/.htpasswd
require valid-user 

.htpasswd

user:$apr1$Xdj0RvXW$quha1UZwlRErZvVE9qgSS/

The .htaccess I generated from here , the user is: user and the password is: test

I do not know if the problem is in the path I indicated in .htaccess or that the password in .htpasswd is not right. Because I tried another website that generates it and the code was different.

Server response

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
    <title>500 Internal Server Error</title>
</head>
<body>
    <h1>Internal Server Error</h1>
    <p>
        The server encountered an internal error or
        misconfiguration and was unable to complete
        your request.
    </p>
    <p>
        Please contact the server administrator,
        [email protected] and inform them of the time the error occurred,
        and anything you might have done that may have
        caused the error.
    </p>
    <p>
       More information about this error may be available
       in the server error log.
    </p>
</body>
</html>
    
asked by 19.06.2017 в 12:51
source

2 answers

1

The problem I had was the routes and passwords.

I've generated a new .htpasswd from here

Now it has this form:

User:{SHA}ZAqyuuB77cTBY/Z5p0b3q3+10fo=
User:$6ExxjO74i0C2
User:$apr1$pzmjdi6v$W0W./I2gCjOsQgJX7RVRW0
User:A donde vas?:55d045b14e09314af8b6e11ae6b65382

The passwords are set in the following formats: sha1 Algorithm , crypt Algorithm , md5 Algorithm , digest Algorithm

The .htaccess file has the following form:

AuthType Basic
AuthName "A donde vas?"
AuthUserFile /home/test/www/test/app/app/.htpasswd
Require valid-user
    
answered by 20.06.2017 / 12:08
source
1

Considerations for the route where the file should be. You need to create a password file and place it somewhere that is not accessible through the Web. For example, if your documents are served from /usr/local/apache/htdocs you should put the password file in /usr/local/apache/passwd . You're putting it in the www directory so it does not seem very convenient.

On the other hand, in the Apache log file, it sends me the error message [Mon Jun 19 13:33:15.405507 2017] [authn_file:error] [pid 6152:tid 892] (OS 3)El sistema no puede encontrar la ruta especificada. : [client ::1:53654] AH01620: Could not open password file: C:/wamp64/bin/apache/apache2.4.23/app/.htpasswd , so I put the file .htpasswd in the indicated path and it works perfectly.

The .htaccess file I used:

AuthType Basic
AuthName "Directorio privado"
AuthUserFile app/.htpasswd
Require valid-user
    
answered by 19.06.2017 в 13:36