Restricting access to web pages:
It is possible to restrict part or all of your personal web pages so only certain people will have access to it.
Start at the root of the directory tree you wish to secure and create a file called .htaccess similar to the one below.
For example, if I want to create a private area under my web site
http://www.cs.sunyit.edu/~merantn/private/, I would edit this file by typing:
vi ~/www/private/.htaccess
And then cut and paste the following text into the file:
AuthUserFile /home/u/csci/merantn/www/.htpasswd AuthName "My Site" AuthType Basic <Limit GET POST> order allow,deny allow from all require valid-user require user merantn mirchr </Limit>
You only need one of the require lines above to either require any valid user, or to list out the usernames of those who are allowed to access the site. This is useful if you want to set up multiple secured areas allowing different users access to each while maintaining only one password file. Usernames and passwords for this example are stored in the file /home/u/csci/merantn/www/.htpasswd. Be sure to change this to the path of your file.
For this example, the .htpasswd file can be created with the htpasswd command. This command can be found on fang and spike.
htpasswd -c /home/u/csci/merantn/www/.htpasswd merantn htpasswd /home/u/csci/merantn/www/.htpasswd mirchr
The -c option on the first line above instructs htpasswd to create a new file. Only use this option if the password file does not exist. You will be prompted to enter passwords for each user. Typing htpasswd on the command line with no arguments will show a list of valid options.
NOTE: Passwords used are sent over the network in cleartext. Do NOT use your login passwords for web access!
Permissions on the files must be set so the web server is able to read the .htaccess and .htpasswd files:
chmod 644 ~/www/private/.htaccess ~/www/.htpasswd
More information is listed on the Apache Site
