Password protect your website

Warning: This tutorial uses .htpasswd and .htaccess. This process will slow down the speed of your website as it checks every directory. You also need an apache server with PHP ability to run this.

What you need:
FTP access to your server
Notepad/Wordpad/...
Basig knowledge of websites

Let's get started:
Open Notepad and create a file. This needs to be in it:

Code:
AuthUserFile Directory
AuthName "Title of log-in screen"
AuthType Basic
Require valid-user
You need to change "Directory" into the directory your website is in. For example:
www/website/members/
You need to change "Title of log-in screen" to something you want. Don't forget to keep the quotes though.

Now, when using notepad, go to save as... and save it as ".htaccess" (without the ""). Don't forget to choose 'all types' and not .txt. Otherwise you can always rename the file to '.htaccess' in the FTP browser.

The .htpasswd needs to contain a username and a encrypted password. A good tool to encrypt passwords is found here:
Code:
http://home.flash.net/cgi-bin/pw.pl
Your htpasswd file looks like this:

Code:
username:p.whLw2ZDZroU

With notepad, save it as '.htpasswd' or again, rename it within the FTP browser.

Everything is set up now, though, make sure you got these things right:
You've put the .htpasswd file in the right directory you specified in the .htaccess file.
You've got the right names. '.htpasswd' and '.htaccess' and you are sure the .'s are there too.
You've put the .htaccess file in the directory on your server you want to protect.
You've encrypted the passwords.

Niciun comentariu: