WP ignores .htaccess ErrorDocument 401
-
I created a protected directory using cPanel. Location is /files/members
cPanel created /files/members/.htaccess as follows:#—————————————————————-cp:ppd
# Section managed by cPanel: Password Protected Directories -cp:ppd
# – Do not edit this section of the htaccess file! -cp:ppd
#—————————————————————-cp:ppd
AuthType Basic
AuthName “Members Only”
AuthUserFile “/home/cnr/.htpasswds/public_html/files/members/passwd”
Require valid-user
#—————————————————————-cp:ppd
# End section managed by cPanel: Password Protected Directories -cp:ppd
#—————————————————————-cp:ppdBoiler plate as can be. For those with experience here, you know that accessing this directory by direct URL (mywebsite.com/files/members, where WordPress 5.6.2 is installed in the root) results in the confusing 404 -page not found error (even though the actual error is 401 – authorization required), instead of the desired directory access credentials popup.
The standard fix is to add “ErrorDocument 401 /401.html” and optionally “ErrorDocument 403 /401.html” in the root WP .htaccess file BEFORE the “# BEGIN WordPress” section. Which I have done, as well as created the 401.html file, placing it in the root.
Guess, what? WP IGNORES this and continues to return 404. No, I don’t have any caching enabled. Changes to .htaccess are picked up immediately on page refresh (I tested with other options/commands/rules to confirm).
Has .htaccess syntax changed in the last 2 years making the above ErrorDocument method invalid or has WP added something I need to address in Settings that’s being overlooked?
According to all the google search hits, adding ErrorDocument to the root .htaccess has fixed EVERYONE else’s 404’s on protected directories, but NOT ME!! Any possible info/help is kindly appreciated.
I have also added “Options +Indexes” beneath “# END WordPress” to allow a file index to be displayed for any directory that doesn’t have a protective index.php intercept file in them. I don’t see how that could cause WP to “ignore” ErrorDocument.
Thanks.
- The topic ‘WP ignores .htaccess ErrorDocument 401’ is closed to new replies.