Password-Protecting Apache Folders
Prerequisite: Make sure .htaccess overrides are allowed for the folder you are protecting!
In the folder being protected create two files:
AuthName "Secured Access"
or if you need to protect just specific file, change the last part of .htaccess to read like:\
For the creation of .htpasswd, in the corresponding folder run:\
htpasswd .htpasswd Johnnie
To change password in an existing .htpasswd for user Jannie:\
htpasswd .htpasswd Jannie