Wordpress - Conflict between WordPress and Password Protected Directories

There is a common conflict between WordPress and password protected directories. If you have setup a password protected sub-directory on your cPanel control panel, but it's not working because WordPress is installed in the main root directory of your website, follow this guide to fix the problem. In this example, the sub-directory which needs password protected is called "secure".

1) In the secure directory, create a new HTML file called oneerror.html

This file will be shown to people who fail to login to the password protected area, so if you like you can put a message in it, for example "Login failed. Please check your credentials."

 

2) In the secure directory, open the .htaccess file (or create a new .htaccess file if it doesn't exist).

In the .htaccess file add two lines:

ErrorDocument 401 /secure/oneerror.html

ErrorDocument 403 /secure/oneerror.html

 

3) Try the website and the password protected directory should now be working.