Issue with .htaccess files and Wordpress
I used the Directory Privacy on cPanel to password protect a sub-folder on the server. I understands it creates a .htaccess file for that folder. However in the sub-folder I have a created a separate HTML website, that without the Privacy on, displays fine. But when I add the privacy, it re-directs to 404 error page within the main wordpress installation.
Additional information - I have a Wordpress installation in the main directory xyz.com, and in sub-folders I have micro HTML based sites for special events. xyz.com/event1 -
No Directory privacy or .htaccess file, the xyz.com/event1 loads fine. However when I add the feature, it goes to wordpress xyz.com 404 page.
I used the same set up on shared hosting, and have gone through the wordpress .htaccess file and they are same on the VPN server as the old shared.
I have also updated the AllowOverride setting to be able to overwrite Apache directives, using the ssh. Changing it to AllowOverride All -- and restarted my Apache. But that did not work.
Is there something am missing?
Thanks
-
Hi, The issue is because a protected directory's subdirectories inherit their parent directory's password protection. The lock iconindicates that Directory Privacy configurations already exist for that directory. Please have a look at this article: - Directory Privacy - Version 60 Documentation - cPanel Documentation - Regards, 0 -
I am not sure I follow. I have no password protection on the main directory, in this case it is the www file. And then the folder in the www - is the one with a lock on it. Sorry, am new to server admin, and trying to figure this out as I go. 0 -
And then the folder in the www - is the one with a lock on it.
You mean to say that you have given the lock on "www" folder? the folder www is linked to public_html directory, so it has lock, then your main site has been locked too.0 -
Sorry -- no I have not given a lock to the www or the public_html directory. The lock was placed on a sub-directory in the public_html file. 0 -
What I've done to fix this in the past is to put the following in the password-protected subfolder's .htaccess file before the entries regarding password protection: ErrorDocument 401 /401.html
Next, create a 401.html in the main (/public_html) folder, with any text, for example:PASSWORD PROTECTED FOLDER - Please enter the correct username/password.
That should allow you to access the password-protected subfolder(s) without getting the 404 on your WordPress site.0 -
Thanks! This worked perfectly. Is there a reason why this happens? Just trying to understand the mechanics behind the fix for future issues if they arise. 0 -
Thanks for updating your thread. 0 -
All I have in my notes to explain why the issue happens with WordPress is that there is a conflict between WordPress' rewrite rule so that it handles all 404 errors in its directory tree and how Apache handles the password-protected folders. Fortunately, the fix above works. Someone else here may be able to explain more. 0
Please sign in to leave a comment.
Comments
8 comments