Here we will cover how to enable Directory Privacy for the wp-admin folder.
With a default .htaccess file in a site that is installed in a subdirectory, enabling Directory Privacy for wp-admin results in a 404 page for the domain.com/wp-admin URL. Without making the below changes, it also allows visitors to use the domain.com/wp-login.php URL to bypass Directory Privacy and attempt to log into the dashboard.
This may also happen when using directory privacy for a specific folder on any site that relies on a redirect, such as PrestaShop.
Adding a line to the .htaccess file should assist with this issue.
Related Articles
Password Protect Directory in cPanel
Unlocking WordPress Dashboard when Locked Out by ModSecurity
Create Default WordPress .htaccess
Modifying the .htaccess File
- Log into cPanel
- Open File Manager, located in the Files section
- Locate the document root of the site
- Locate the .htaccess file for the directory where Directory Privacy has been enabled
- Right-click on the file and select Edit
- Right-click on the file and select Edit
- Insert the following line to the top of the file:
ErrorDocument 401 "Authorization Required"
- Save the changes by clicking Save Changes at the top-right of the screen