How to password protect a web site

There are a number of ways to prevent people accessing directories on or your entire web site. One of the most secure is using a .htpasswd file
  1. Create a file - .htpasswd - with the username and password for the directory you want to password protect
  2. Open it, and make up a username and password. Put them both on one line, separated with a colon. There shouldn't be any spaces
  3. You must encrypt the password. Here is a site to help you: http://home.flash.net/cgi-bin/pw.pl
  4. Now create a .htaccess file in the directory you want to protect, and add this to it:
    AuthUserFile /home/user/www/.htpasswd
    AuthGroupFile /dev/null
    AuthName "User"
    AuthType Basic


    <Limit GET POST>
    require valid-user
    </Limit>


    You need to change the first line to reflect the location of your .htpasswd file
  5. Now when you go to the directory, you will be asked for your username and password before you can access the protected directory

Copyright © A-ZTutorials.com. All Rights Reserved | Privacy Policy | Contact
Disclaimer: A-ZTutorials.com is not responsible for any damage caused as a result of using one of our tutorials