how to set up htaccess

htaccess can be used with apache to provide password authentication on your website.

open your httpd.conf

find this section:
<Directory />
Options FollowSymLinks
AllowOverride None

add this below it:
<Directory "/usr/local/apache/htdocs/admin">
AllowOverride AuthConfig
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all

once this section is added in, restart apache using apachectl restart

change into the directory you want to protect. then create a new file using vi .htaccess and add the following to it:

AuthUserFile /var/www/htdocs/site/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user

to add a new user, run
htpasswd -c /usr/local/apache/htdocs/admin/.htpasswd username

run apachectl restart after you have added new users.

browse over to your site and test out if everything works.