Protecting Directories with .htaccess
Change to the directory you wish to password protect.
Create a file called .htaccess inside that directory:
# touch .htaccess
Now you must create .htpasswd that will hold the username and encrypted
password of users allowed to access the directory.
Create .htpasswd outside of the web root with the following command:
# htpasswd -c /path/to/.htpasswd <username>
# <enter the password for the user>
Use your favorite text editor to add the following to .htaccess:
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require valid-user
Edit httpd.conf and change:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
to read:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>