How do I protect a directory with a password?
Updated on 3 November 2026
Anyone can reach the subdirectories of public_html with a web browser.
But suppose you want to restrict access to one particular directory. You can do this from cPanel by clicking 'Directory Privacy' under the 'Security' heading.
You will find a list of subdirectories there. Click the folder icon to the left of public_html to see its content. You will now see the subdirectories of public_html. To select a subdirectory, click its link. On the security settings page, tick the box 'Password protect this directory'.
In the 'Name of the protected directory' field, enter the title you want to give the selected directory, 'My protected folder' for example. Click the 'Save' button. Go to the bottom of the page. Create a username and a password that will be used to access this folder. Press the 'Add/modify authorized user' button. Now go to your website and check that the chosen directory is indeed secured with the details you provided.