Create .htaccess and .htpasswd


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.


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



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

    <title>500 Internal Server Error</title>
    <h1>Internal Server Error</h1>
        The server encountered an internal error or
        misconfiguration and was unable to complete
        your request.
        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.
       More information about this error may be available
       in the server error log.
asked by 19.06.2017 в 12:51

2 answers


The problem I had was the routes and passwords.

I've generated a new .htpasswd from here

Now it has this form:

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

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