SOLVED Issue with .htaccess files and Wordpress

elpaulli

Member
Jan 17, 2017
6
0
1
United States
cPanel Access Level
Website Owner
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
 

NOC_Serverpoint

Well-Known Member
Jul 3, 2016
102
6
18
cPanel Access Level
Website Owner

24x7server

Well-Known Member
Apr 17, 2013
1,894
91
78
India
cPanel Access Level
Root Administrator
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.
 

linux4me2

Well-Known Member
Aug 21, 2015
240
64
28
USA
cPanel Access Level
Root Administrator
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:
Code:
ErrorDocument 401 /401.html
Next, create a 401.html in the main (/public_html) folder, with any text, for example:

Code:
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.
 

linux4me2

Well-Known Member
Aug 21, 2015
240
64
28
USA
cPanel Access Level
Root Administrator
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.