The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Issue with .htaccess files and Wordpress

Discussion in 'General Discussion' started by elpaulli, Jan 19, 2017.

  1. elpaulli

    elpaulli Member

    Joined:
    Jan 17, 2017
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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
     
  2. NOC_Serverpoint

    NOC_Serverpoint Well-Known Member

    Joined:
    Jul 3, 2016
    Messages:
    102
    Likes Received:
    6
    Trophy Points:
    18
    cPanel Access Level:
    Website Owner
  3. elpaulli

    elpaulli Member

    Joined:
    Jan 17, 2017
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    United States
    cPanel Access Level:
    Website Owner
    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.
     

    Attached Files:

  4. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,404
    Likes Received:
    53
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    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.
     
  5. elpaulli

    elpaulli Member

    Joined:
    Jan 17, 2017
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    United States
    cPanel Access Level:
    Website Owner
    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.
     
  6. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    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.
     
  7. elpaulli

    elpaulli Member

    Joined:
    Jan 17, 2017
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    United States
    cPanel Access Level:
    Website Owner
    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.
     
  8. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    15,618
    Likes Received:
    296
    Trophy Points:
    433
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Thanks for updating your thread.
     
  9. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    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.
     
Loading...

Share This Page