Skip to main content

Password Protected Folder Returning 404 Error

did you have 404 Error when you tried to use Basic Authentication to one of your directory ?

please follow this steps to solve it

 

Assuming the following directory structure:

  • /public_html/ – where WordPress is installed
  • /public_html/protected_dir/ – the password protected directory (“protected_dir” = whatever you named the directory)

When you create a password protected directory in cPanel, it adds a .htaccess file to that protected directory. The .htaccess most likely looks something like this:


AuthType Basic
AuthName "Example Directory Name"
AuthUserFile "/home/example/.htpasswds/public_html/protected_dir/passwd"
require valid-user

Try doing the following:

In the protected directories .htaccess file (/public_html/protected_dir/.htaccess), add ErrorDocument 401 /401.html before the existing authentication directives. Example:


ErrorDocument 401 /401.html

AuthType Basic
AuthName "Example Directory Name"
AuthUserFile "/home/example/.htpasswds/public_html/protected/passwd"
require valid-user

Now, in the main /public_html directory, create a file named 401.html. Enter whatever you’d like in the file. Something along the lines of “Password Protected Directory – Enter your username & password”.

 

reference :

https://wordpress.org/support/topic/password-protected-folder-returning-404-error/