• Resolved iamkangy

    (@iamkangy)


    Hello,

    I have created a private (not called that obviously) folder under my public_html directory, the same directory where my WP install is.

    I have made that folder password protected through cPanel. However, the problem is that when I go to the link for that directory it gives me a wordpress 404 Error Page. It does not even prompt for the username and password to access that folder.

    How can I resolve this problem please as I need to have this folder password protected.

    Thank you in advance for your assistance in sorting out my issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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”.

    Does that do the trick?

    Thread Starter iamkangy

    (@iamkangy)

    Hi Christopher. Thank you for such a speedy reply. I just followed your instructions and it worked perfectly. Thank you so much ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Password Protected Folder Returning 404 Error’ is closed to new replies.