Hack Forums
Password protect a folder with .htpasswd? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: Password protect a folder with .htpasswd? (/showthread.php?tid=2758070)



Password protect a folder with .htpasswd? - Webman.io - Aug 8, 2012

How can I password protect a folder by using .htpasswd?

I would aswell like the username and password to be this:
Username: Skipper
Password: sandmanden


* - PhineasPhreak - Aug 8, 2012

First you'll want to create a ".htpasswd" file that contains the following:
Code
Skipper:25Rknpxf64TbA
The code at the end is just your password encrypted. Don't worry your host will understand this!

Then you make a ".htaccess" file that contains something like this:
Code
AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "My Protected Folder"
Require valid-user
Change "/full/path/to/" to the path where you placed your .htpasswd file
AuthName is the header that will come up when someone tries to access your protected folder!
Place the .htaccess in the folder that you wish to protect and it should now be password locked.

Note: The .htpasswd does not need to be in the folder that you want to protect, it can be anywhere but you must place the path of where it is in the .htaccess file. The .htaccess MUST be in the folder you want to protect.

Note2: Try and upload .htpasswd to a place that is not publicly accessible (like your root directory) or use CHMOD to change the permissions for that file so no-one can just easily view it.


* - MuGen-7 - Aug 8, 2012

To password protect directory:

1 Login into your cPanel and click on the Password Protect Directories icon, found under Security.
2 Choose Web Root (and you may need to select Show Hidden Files)
3 Click on the name of the directory that you wish to password protect.
4 Check the box for "Password protect this directory:"
5 Fill in "Name the protected directory". Actually, this is just the message that will show to visitors when they try to login, and can be anything you like.
6 Click on Save button below.
7 Click "Go Back"
8 Fill in a Username and Password at the bottom of the page, and click "Add/modify authorized user".

You are done. The directory you selected is now protected by password

Also a Video tuto in Youtube : http://www.youtube.com/watch?v=lqk44fXJF4Q&feature=player_embedded#!