Create an .htaccess file and enter the following code.
AuthUserFile /home/user/www/.htpasswd1) Change the AuthUserFile to the path on your own server.
<Limit GET POST>require valid-user</Limit>
2) Change the AuthName to whatever you want. No spaces
3) Save the file .htaccess
As you can the AuthUserFile points to a file called .htpasswd
As the name suggests this is where your username and password will be stored. The next thing we need to do is create the .htpasswd.
To generate the password you may need to visit a website.
I found the following site at http://www.htaccesstools.com/htpasswd-generator/
Enter the username and password.
Copy the code on the next page. The username and password is in the following format.
test:$apr1$lwFL0YZG$Nps4uKqMX8.QDu2wXk.C51Now that you have copied the code, copy this in to a file and save it as a .htpasswd file.
You should now have two files. .htaccess and .htpasswd. Connect to your webspace and upload these to your root directory.
If everything was succesful you will be prompted for your username and password.