password protect directory with .htaccess

2020-03-30 04:00发布

Hi I am trying to password protect a directory with .htaccess. I have created a .htpasswd file and stored it at the root of the server. I have created a .htaccess file in the directory I want to protect with the following lines:

AuthUserFile /home/baltzers/domains/baltzersciencepublishers.com/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
AuthName "restricted area"
require user test

But when I fill in my username and (encrypted) password, it keeps throwing back up the authentication dialog. What am I missing?

标签: .htaccess
3条回答
萌系小妹纸
2楼-- · 2020-03-30 04:20

You mught want to replace the line require user test with:

require valid-user

Otherwise, the user must be named "test" and exist in the .htpasswd file.

查看更多
祖国的老花朵
3楼-- · 2020-03-30 04:31

You need to use the unencrypted password when logging in. Note that unless you're doing the whole chain encrypted (i.e. you're using https instead of http) then the username and password will be sent in the clear.

查看更多
Lonely孤独者°
4楼-- · 2020-03-30 04:47

Try this: http://tools.dynamicdrive.com/password/

The tool will create the files you need based on your form input.

查看更多
登录 后发表回答