Password protecting a website folder PDF Print E-mail

Sometimes you just need to do this directly. There are lots of utilities in server administration programs such as cpanel, plesk or virtualmin that will do this for you but if you have shell access here is the quick way.

First edit your .htaccess for the relevant folder (your root folder if you want to protect the whole website) to tell apache that it is only going to allow access to the specified user by adding these lines to the top of the file (make sure path is not in your accessible web folders - your home folder is usually a good place.:

AuthUserFile <path>/.htpasswd
AuthName "Under construction"
AuthType Basic
require valid-user

Next create at least one valid user in the .htpasswd file with:

~$ htpasswd -b .htppasswd test test

This creates a user 'test' with the password 'test'. You may need something a little more secure but this will be enough to deter casual browsing and bots.

Trackback(0)
Comments (1)Add Comment
0
...
written by pokies, March 29, 2012
it works! thanks

Write comment

security code
Write the displayed characters


busy
 
We have 46 guests online
Paul Whipp Consulting (BN 207 530 56) is owned by and operated for The Whipp Family Trust (ABN 32 507 522 641).