How To Password Protect Your Directories
How It Works
A Password Protected directory will protect ALL files AND ALL subdirectories within. No one will be able to get a list of files within that directory without having a username and password for that directory. They won’t be able to open or view a file without access even if they no the exact URL (link) to that file. This system uses .htaccess files to manage passwords. It’s a great way to protect files and configure simple file sharing between users.
Getting Started
Login to your cPanel (For more information on Logging into Cpanel, click here). Select “Password Protect Directories” from the menu.
You will be presented with a list of files and folders within your base directory. Let’s browse to the directory you wish to setup a user for. Click on the Folder Icon
to “go into” that directory. (Don’t click on the folder name - that is how you set user permissions for the folder). Directories that are already protected will have a lock icon
next to them.
Once you have browsed to the directory you’d like to protect, click on the name of the directory. If you have not protected this directory yet, click the checkbox next to the
icon. Also, type in a title for this protected area of the website. This title will show up on the Login Box when a user attempts to login. Now, click the SAVE button. This directory is now protected–now we need to add users.
Setting Up User Access
The the same page is a list of Active Users. This box may be blank if there are none setup. Let’s setup our first user. Simply, type in a Username and Password for this user. Click the “Add/modify authorized user” button to save this user.
Editing or Deleting a User
You’ll notice that this user shows up in the Active Users list. To delete this user, just click on their username and click the “Delete User” button.
To modify a user, type in their username (case-sensitive) into the Username box, and enter in a new password.
The only way to change a user’s username is to delete them and then recreate them with the new username.
Tell Your User Where To Access the Files
We need to give your user a URL (link) to their directory. While your on the User setup page for this directory, look at the directory path near the top of the page.
Example: /home/websitename/public_html/files/myfolder
The public_html directory is your actual website directory–it’s your web address directory. This means that you replace “/home/websitename/public_html” with “http://www.your-webesite-name.com“ and add the sub folders to it (”/files/myfolder“).
Example Result: http://www.your-website-name.com/files/myfolder
When the user goes to this URL. They will then be prompted with a Login box.
Note: As you read above, password protecting directories will protect ALL files and sub-folders within. If you would password protect a folder, and then password protect one of it’s sub folders, your user will get 2 Login boxes. Be careful not to do that.
