: Htaccess , htpasswd and error 401 I have a problem with htpasswd. I get an error in error.log apache2 user admin: authentication failure for "/": Password Mismatch Content of my htaccess
I have a problem with htpasswd.
I get an error in error.log apache2
user admin: authentication failure for "/": Password Mismatch
Content of my htaccess file:
# Set Access Restrictions
AuthType Basic
AuthName "admin"
AuthUserFile ".htpasswd"
require valid-user
and content of my htpasswd
admin:xxxxx
More posts by @Sarah324
3 Comments
Sorted by latest first Latest Oldest Best
Finally, I have not hash a password to md5 .... I've used notepad ++ and I put the password in simple character
I followed this tutorial with the linux command for create file htaccess
now my content of my htpasswd :
admin:$apr1$Oy4JMDb0$yb00PbzV9mrq07lPivrzL1
From your comment I take it that you just created a plain text password. This will not work for Apache, as Apache expects the password in .htpasswd to be hashed by the MD5 algorithm.
There are several tools available online for generating .htpasswd files, but the easiest might be the one that comes with Apache, it's called htpasswd. On RHEL (Fedora, Red Hat, CentOS) systems you'll need the httpd-tools package (yum install httpd-tools). On Ubuntu systems it's in the apache2-utils package (apt-get install apache2-utils). If you're using XAMPP on Windows it's in the folder xamppapachebin.
To use htpasswd with the .htaccess file you've already got configured, you'd simply do htpasswd /protected/.htpasswd user and then type in your desired password (twice) when prompted. It will then generate your .htpasswd file in the /protected/ directory.
Make sure that you are including the entire path for AuthUserFile. I would suggest that you create a protected directory instead of doing this on the root directory. I made sure and tested these configurations to ensure that they worked.
File Locations
/protected/.htaccess
/protected/.htpasswd
.htaccess File
AuthType Basic
AuthName "restricted area"
AuthUserFile /protected/.htpasswd
require valid-user
. htpasswd File
user:password
Make sure that the password is MD5'd, here is a tool.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.