If you like to password protect a directory on your web server, just create a
.htaccess file into such a directory and put the following code:
AuthName "Restricted Area"
Then, generate the corresponding
.htpasswd file by executing the following command:
/path/directory/protect$ htpasswd -c .htpasswd admin
Re-type new password:
Adding password for user admin
Reload your web directory and enter the credentials you’ve just chosen.