Protecting Your Web Pages

[ICAT4194A - Ensure Basic Website Security]

At the simplest level making sure your home page is called index.htm will stop web browsers from displaying all the files in your top directory.

At a more sophisticated level you may wish to protect your Web pages from prying eyes and restrict access to just friends.

As your files are stored on cybil, a unix box, we can implement this by using two files
.htaccess and .htpasswd

.htaccess is a plain text file that is placed in the directory you wish to protect.

Remember unix is case sensitive so check your spelling carefully.

It contains the follow
AuthUserFile /home/youraccount/public_html/.htpasswd
AuthGroupFile /dev/null
AuthName "A Username and Password is Required to Enter this site"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

In the first line replace youraccount with your account name.

In the third line the quoted text can be whatever you want.

The file .htpasswd is created with the htpasswd command.

To run the command
Log in to your account on cybil, change to the public_html directory and type

/usr/bin/htpasswd -c .htpasswd yourname

You should now have a file called .htpasswd in your public_html account.

To give other people access to your pages use the same command without the -c switch and with a different name

Now your entire website is protected from access.

You may wish to protect only part of your website, for example, access to membership lists or forums.

One solution is to put this section into separate directory and running the command in that directory.
In that way everyone can access your website but only those with a password can access the restricted section.

Exercise
Protect part of your site using the two techniques (index.html and .htaccess) outlined above.