HTACCESS is able to protect folders with passwords. To password protect folders you should mention the location of .htpasswd – a file that contains the username and password to unlock the folder.
First of all create a .htaccess file if doesn’t exists and create a .htpasswd file.
Now Add username and password to the .htpasswd file which you can get from this simple tool.

Add the following text in .htaccess :

AuthName “This folder requires a login”
AuthType Basic
AuthUserFile /home/simsu/projects/TestPalace/Blog/Password_Protect/.htpasswdAuthGroupFile /dev/null
require valid-user

Replace the red highlighted text above to the location of the .htpasswd file. Now open the folder on the site and you will get a screen like below :