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
- In cPanel open Directory Privacy.
- Browse to the folder. Click its name to open it, or click the folder icon beside it to select it.
- Tick Password protect this directory, give it a name, and click Save.
- 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
.htaccessis 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.