How to Password Protect a Drupal Site using Apache htaccess

 
If you're a developer working on a Drupal site yet-to-be released, password protect the site using the Apache htaccess facility.
 
Edit the file DRUPAL_ROOT/.htaccess to add lines similar to these:
 

# Require popup dialog for access
AuthType Basic
AuthName "You must give a password"
AuthUserFile /home/me/.htpasswd
Require valid-user

 
Now, create the password file with a username and password in it, in the example below, the username is FOO:
 

htpasswd -c /home/me/.htpasswd FOO
New password: BAR
Re-type new password: BAR
Adding password for username FOO