It can be done with .htaccess file, but in linux modifying httpd.conf, if you can access, seems more efficient:
just below:
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
Allow from 127.0.0.1
adding some lines like the following:
# blab blab …
<Directory “/path to you website/the directory you want to control”>
Order deny,allow
Deny from All
#Allow from 127.0.0.1
AuthType Basic
AuthName “Password Required”
AuthUserFile “/somewhere/your passwd file”
Require valid-user
# AuthGroupFile /www/passwords/group.file
# Require Group admins
Allow from 127.0.0.1
Satisfy Any
</Directory>
then in xterm, use htpasswd command:
htpasswd “passwdfile” username
at the prompt, input the password
That’s it.