How to make a folder password protected

Sometimes it’s needed to make a folder password protected to enhance security. Let you have a site with admin end where admin area is already password protected using script but you extra security. Or you have a folder with url which is accessible to certain user with given access. This can be done easily using htaccess.

To do this you have to create two files. One file is .htaccess file which will contain information of  user access file. Let the username, password’s information file is .htpasswd . First create the .htpasswd file using any text editor. Generate username and password and put them inside your .htpasswd file. There are a list of online tools which generate .htpasswd username and password. Just use google search for them.

Ok, now you have the .htpasswd file ready. Upload it on your host root folder or somewhere else which is very secured and inaccessible through url. Now create .htaccess file. Put the following code( modification needed with your aspects)

AuthUserFile /home/user/.htpasswd
AuthGroupFile /dev/null
AuthName “Private Area”
AuthType Basic
<Limit GET POST>
require valid-user

This is pretty straight forward and self-explanotory.  You have to modify the first line to locate your .htpasswd file.  After make this file ready, upload .htaccess file to that folder which you want to protect.

That’s it.

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.