Thursday, December 18, 2014

basic authentication on http directory with .htaccess

1- create file .htaccess in the directory, you want to have password protected with the following content

AuthType Basic
AuthName "My Protected Area"
AuthUserFile /etc/.htpasswd
Require valid-user

2- create file /etc/.htpasswd
-for first time
root@htaccess:/# htpasswd -c /etc/.htpasswd user1

-- when add new user

root@htaccess:/# htpasswd /etc/.htpasswd user2

3- when access to the directory it will prompt to input username/password

No comments:

Post a Comment