You can password protect directories (folders) via cPanel, protecting all the files within the password protected folders.
Any file that needs protection can be placed in a protected directory.
To password protect a directory:
- Log into your cPanel and click on the Password Protect Directories icon found under Security.
- Choose Web Root (you may also need to select Show Hidden Files)
- Click on the name of the directory that you wish to password protect.
- Check the box for Password protect this directory.
- Fill in Name the protected directory field. This will be the message shown to visitors when they try to login and can be anything you like.
- Click on the Save button below.
- Click Go Back.
- Fill in a Username and Password at the bottom of the page, and click Add/modify authorized user.
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.
404 Error When Using a URL with a Shared Server SSL
If you are accessing a password protected directory with a URL that includes the use of a shared server SSL and receiving a
404 error, this is becauseĀ Apache is looking for a 401 page and serving a 404 when it is not found.
To resolve this, add a single line to the .htaccess file in the protected directory, to give Apache the 401 page it is looking for (ErrorDocument 401 "Authorization Required").
