If you wish to provide provide protection to some folder (/var/www/html/test) in Apache then follow the steps below.
■ Create Folder and Password File .htpasswd in /var/www/html/test
# mkdir -p /var/www/html/test
# htpasswd /var/www/html/test/.htpasswd user1
■ Now create .htaccess file in same folder (/var/www/html/test)
# nano /var/www/html/test/.htaccess
AuthType Basic AuthName "My Protected Folder" AuthUserFile /var/www/html/test/.htpasswd require valid-user
■ Now edit httpd.conf file and add following content for the respective folder in VirtualHost Block.
<Directory /var/www/html/test> Options Indexes Includes FollowSymLinks MultiViews AllowOverride AuthConfig Order allow,deny Allow from all </Directory>
Restart Apache Server and check the same using browser.
# elinks http://station1.example.com/test
It should come up with Popup Window. Put your user name and password to get access.