Create the password file:
htpasswd -cm /etc/httpd/SITENAME-htpasswd USERNAME
Then enter the user’s password twice.
Next, update the .htaccess file in the directory that the user would like protected. These are the important lines:
- AuthType Basic
- AuthName “Password authentication required”
- AuthUserFile /etc/httpd/sitename-htpasswd
- require valid-user
Then you’re good to go! Just make sure that “AllowOverride” is set to “All” for the virtual host so that the .htaccess file is being read