How to create basic HTACCESS login to secure your web folder from public access?

by   SJRANJAN

HTACCESS login system was used to protect a webfolder from public access. Especially it was used to protect admin section(folder) of any website which got only specific user access. This enables a two layer of authentication which was more secured.

htaccess

 

To enable HTACCESS login, you need to place two files into the folder on which you want to enable.

1) .htaccess
2) .htpasswd
.htaccess file holds the lines to prompt the user for a valid login.
.htpasswd file holds the login information for allowed users.
Steps to enable htaccess login in your folder…
Place .htaccess file inside your folder with following lines…

On the above code…

Replace  “MESSAGE TO USER” with a valid prompt message. (i.e. This is private area … Please login to continue …)
Replace “PATH TO HTPASSWD FILE” with the location where your .htpasswd file location (i.e. /home/xxxxx/public_html/administrator/.htpasswd)
Example code…

Now place the .htpasswd file with login information for allowed users.

To create .htpasswd users entry use the following URL…
http://www.htaccesstools.com/htpasswd-generator/
Generate user entrys from the above URL and place it line by line in the .htpasswd file
Thats all … You are done with simple HTACCESS login setup… Now if you try to access your folder in your browser (i.e. http://www.yoursite.com/administrator) , you will be prompted to login to see the folder content.

Video Tutorial

http://www.youtube.com/watch?v=DxcZn_EskVM

Share on :