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
- In cPanel open Directory Privacy under Files.
- Browse to the folder you want to protect and click Edit beside it.
- Tick "Password protect this directory" and give it a display name.
- Click Save.
- 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.