How to Password-Protect a Directory Using .htaccess in cPanel
If you want to restrict access to a specific folder on your website, cPanel allows you to password-protect a directory using a simple interface. This feature generates a .htaccess file that requires a username and password to access the directory and all of its subdirectories.
Steps to Enable Directory Protection
- Log in to your cPanel account.
- Click on the "Directory Privacy" or "Password Protect Directories" option.
- Navigate to the folder you wish to protect by clicking the folder icon next to
public_html. - Click on the folder name to open its protection settings.
Setting up Protection
- Check the option "Password protect this directory".
- Enter a name for the protected area (e.g., "Private Area").
- Click Save to activate the password protection.
Creating an Authorized User
- Choose a Username for login.
- Enter or generate a secure password.
- Click Save to finalize the setup.
Now, access to the folder will require the username and password you just created.
Important Note
Make sure to keep your credentials safe. After 7 consecutive failed login attempts, the server will temporarily block the IP address for security reasons.