Password-protecting a folder Print

  • directory privacy, password protect, htaccess, security
  • 0

Put a login box in front of a folder, for example a staging copy of your site, a private download or an admin area.

Steps

  1. In cPanel open Directory Privacy.
  2. Browse to the folder. Click its name to open it, or click the folder icon beside it to select it.
  3. Tick Password protect this directory, give it a name, and click Save.
  4. Under Create User add a username and a strong password, then click Save.

Visitors now see a browser login prompt when they open anything in that folder. Add as many users as you need and remove them any time.

For a folder with several accounts, Leech Protection (also under Security) can lock out a login that is being shared too widely.

If it doesn't work

  • You get a 500 error or a loop after enabling it: another rule in .htaccess is in the way. Look at the file (Showing hidden files and .htaccess in cPanel) and compare with your backup copy.
  • The login prompt never appears on a WordPress page: WordPress may be handling that address itself. Protect a real folder, or use a login plugin for WordPress pages.
  • This is a basic lock, not a safe for secrets. Use HTTPS (Forcing HTTPS) so the password is not sent in the clear.

Was this answer helpful?

« Back