You can lock a directory with a username and password so that anyone who attempts to open it must go through its login process. You can secure specific directories on your server. This feature simply modifies
htpasswd configurations to restrict access to those files on your websites.
To use the feature, simply login to the cPanel of your server and select a directory to manage:
- To select a directory, simply click the desired directory’s name
- To view and select subdirectories, simply click the parent directory’s name and select the desired subdirectory
- To configure the security settings for a directory or subdirectory, simply click the Edit option present under the Actions column
- To password protect the selected directory, select the password protect this directory checkbox
- Enter a display label for the directory in the enter a name for the protected directory text box
- Click the Save button and a confirmation message will appear
- Click Go Back to return to the directory’s configuration page
- In step number four, to remove the password protection from a directory, simply deselect the Password protect this directory checkbox and save your changes
- In step number five, This name only functions as a label for the directory. So do not confuse it with the directory’s main name
Once you have locked your directory by completing the above-given steps, you will need to create a user that can have access to that directory.
To create a user for a directory, your directory must have correct permissions. In case you cannot create a user, then change the directory’s permissions to 0700 using the file manager interface.
To create an authorized user:
- On the same page, enter the desired username in the Username text box
- Enter and confirm the new password in the appropriate text boxes
- Click Save and a confirmation message will appear
- Now click Go Back to return to the directory’s configuration page
A protected directory’s subdirectories inherit their parent directory’s password protection. The lock icon indicates that Directory Privacy configurations already exist for that specific directory.
It does not protect the directories that users access via FTP, SFTP, Web Disk, and other similar services, or if any user accesses the files locally on the server. This is because when a user accesses secure directories on a server via these specified services, he already goes through the login process so the system doesn’t prompt him for another login.
In case you want to secure your directories and files locally on the server then use the file and folder permission option.