In my website having sub folder, so I trying to protect that folder files using .htaccess
and .htpasswd
.
Root Folder
Root Files
Sub Folder
Sub Folder Files
.htaccess
.htpasswd
-- Root Files
.htaccess code looks like below
AuthType Basic
AuthName "My Protected Area"
AuthUserFile ./.htpasswd
Require valid-user
And .htpasswd code looks like below
test:pass@word1
When I enter the http://10.10.10.11/website/subfolder/test.html it's prompted the password, I entered but it's throwing error. See below image.
.htaccess
AuthType Basic
AuthName "restricted area"
AuthUserFile ./.htpasswd
require valid-user
If you don't want to use online password generator, you could use openssl
openssl passwd -apr1 pass@word1
Then put the generated password to .htpasswd with format:
username: Example:
.htpasswd
username:$apr1$h81U4v3.$8Msypa0Kx2hQ/C0948BuV1