HostGator.com » Support Portal

Password Protect Directories icon

To password protect directory:

Wait! Why read this when you can watch the movie tutorial here?

Note: At this time, cPanel can only protect directories, not individual files. Any file that needs protection can be placed in a protected 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".
  9. You are Done. The directory you selected is now protected by password.

Warning! This password has a maximum of 8 characters. Any characters typed beyond the first 8 will not be required by visitors.

To ensure your directory has been password protected, launch your browser and view the directory. If the browser prompts you to login, then your folder has been password protected.

500 error after login?

Check the folder ownership on the .htpasswds folder (above public_html). Change them from user.user to user.nobody and ensure the permissions are set to 750 and then refresh your protected page. The error will be gone. Note: Shared and reseller customers will need HostGator's help to change any file's ownership. Please join us in live chat or on the phone for this change.


Article Comments

Bob
How do I set a log out, time or panel, for a Password Protected directory? What is the standard auto log out time duration for a normal password protected dir?

HostGator
The session should end when you close the browser or clear the cookies. There is no log-out link or button.

I recommend using a PHP session, as those can be managed by the web designer. To use PHP sessions, you will need to locate a PHP script with this as a customizable feature.

Google for "secure login php script".

Zafar
Why it is necessary

HostGator
This is not something required, but would be useful if you want to hide pages and files in a certain directory from the public, but allow access to authorized people who have a password.

HostGator
Thank you for your comments. Just a quick reminder that the comments on this page are not monitored by technical support staff, and that for support issues, it is best to contact us by live chat, phone or email so we can assist you right away.

Although comments are not monitored by technical support staff, they are moderated and read by technical writers. Comments will need to be approved by a moderator before appearing.

Our technical writers do read the comments periodically for the purposes of updating the articles, and do appreciate your feedback, suggestions and corrections to the articles themselves, as well as any suggestions or tips for readers of this article. However, support questions posted here are not guaranteed to be replied to in a timely manner or at all. For support issues, it is best to contact our support staff instead by live chat, email or phone.



Your comments help us keep the knowledge base updated. This is not a medium for support. If you have questions or need help, please contact us via email, phone or live chat for fast assistance.

Post Comment