To password protect a folder in Apache, create a password file
[root@server12 ~]# htpasswd -c /path/to/.htpasswd admin New password: Re-type new password: Adding password for user admin [root@server12 ~]#
This is create a password with user user “admin”.
This file should be outside Apache document root.
Now create a .htaccess file with following content in the password protected folder.
AuthUserFile /path/to/.htpasswd AuthName "Members Only" AuthType Basic Require valid-user
To access the folder, you will need to login as admin user created above.