There is a very simple and quick way to protect a website or web directory using .htaccess and .htpasswrd. This can be a very efficient way for web designers to protect web pages or sites in progress. The effect will be that any user trying to access the protected directory will be prompted by a password request.
First start with .htaccess:
You will need to define the exact path to your document on the web server. If you are running PHP, you can run the phpinfo(); on a web page to locate the true path to that document or directory. You will actually mark a path to the .htpasswrd file.
/home/domains/example.com/html/directory/.htpasswd
AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/the/directory/you/are/protecting/.htpasswd
require valid-user
username:password
You can use encryption for the .htpasswrd for added security. There are a number of tools out there for simple password encryption. Two options are listed below, but there are a number out there for encrypting htpasswrd. You could try a simple Google search for "htpasswrd encryption" to find more options.
Two free htpasswrd encryption options: