these are the steps to protect a single file in a directoy by a password.
For example: The folder /var/www/html is and the file you want protect is called internal.html
Define a username (here “agent”) and create a password file (.htuser)
root@debdevt # htpasswd -c -B /var/www/html/.htuser agent
create a .htaccess file in the folder /var/www/html with content:
AuthName "Only for Agents"
require user agent
Note:The AuthUserFile must contain the absolute path to the .htuser file.
That’s it 🙂