In this article we see make folder password protected
Add given below in .htaccess file in the folder you want to protect:
AuthType Basic AuthName "This Area is Password Protected" AuthUserFile /full/path/to/.htpasswd Require valid-user
Preferably, the .htpasswd file will be not in a public facing folder. Add this in there:
That is just an easy, you can generate the code with your unique user and password here.
Note: that all subdirectories of this folder will also be password protected by this same system.