Knowledgebase

Password-Protecting a Folder with Directory Privacy Print

  • cpanel, password, wordpress, php, bruteforce, htaccess, staging, guide
  • 0

Directory Privacy puts a browser password prompt in front of a folder, handled by the web server before any application code runs.

SETTING IT UP

  1. In cPanel open Directory Privacy under Files.
  2. Browse to the folder you want to protect and click Edit beside it.
  3. Tick "Password protect this directory" and give it a display name.
  4. Click Save.
  5. Go back into the same screen and create a user with a strong password under Create User.

GOOD USES

Staging or development copies of a site, keeping them away from the public and out of search engines. An internal documents folder. Placing an extra layer in front of wp-admin against brute-force bots.

IF YOU PROTECT WP-ADMIN

You must exempt admin-ajax.php or front-end forms and carts will break for visitors. Add this to the .htaccess inside wp-admin:

<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>

REMOVING PROTECTION

Return to Directory Privacy, open the folder, untick the box and Save. If you lose the password, this is how you recover access.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot