To set an HTTP Basic Authentication password on a sub-directory within the Apache document root directory tree:
- select the password file to use (this file can be created using the htpasswd command).
- Create the .htaccess in the directory that is to be protected.
- Within the .htaccess file, place Apache configuration directives similar to below.
- Create the username/password combination for login to the directory.
Ref: