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.

protect directory password

Discussion in 'Data Protection' started by k2tec, Apr 22, 2015.

  1. k2tec

    k2tec Well-Known Member

    Joined:
    Aug 26, 2011
    Messages:
    81
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Netherlands
    cPanel Access Level:
    Root Administrator
    I tried to protect a dir in public_html with cPanel server apache 2.4
    Home >> Security >> Password Protect Directories
    Than I say protect this dir and saved it.
    Than I created a user for that dir.

    It create this htacces in that dir:
    AuthType Basic
    AuthName "username"
    AuthUserFile "/home/user/.htpasswds/public_html/userdir/passwd"
    require valid-user

    But now when I go to that dir it does not ask me to login.
    It gives me this page is not found.


    Than I changed the file in my dir to this:
    AuthType Basic
    AuthName "brasilmin"
    AuthUserFile "/home/brasilla/.htpasswds/public_html/brasilmin/passwd"
    require valid-user
    ErrorDocument 401 "Authorisation Required"

    Now it works, but why does not cpanel create this file right
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,447
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Remove any changes you made, create the user first, then protect a dir.

    Does that work as expected for you?
     
  3. k2tec

    k2tec Well-Known Member

    Joined:
    Aug 26, 2011
    Messages:
    81
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Netherlands
    cPanel Access Level:
    Root Administrator
    Thanks Infopro,
    I tested it on 2 different server, but on test accounts. It work both ways.
    First created a the dir I want to protect than the user.
    Than I deleted the htaccess and create first the user and than the dir

    If I got time I will test that account of the customer.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you elaborate on why you are manually changing the .htaccess file? The option you are using in cPanel will update that file automatically.

    Thank you.
     
  5. k2tec

    k2tec Well-Known Member

    Joined:
    Aug 26, 2011
    Messages:
    81
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Netherlands
    cPanel Access Level:
    Root Administrator
    When I created a password dir (normal with cPanel) for that custumer it did not work for that account.
    It was not possible to access that dir ( not found) Then I put that line : ErrorDocument 401 "Authorisation Required" at it worked.

    In post 3 I created the normal cPanel way and worked and thill now that customer account was the only account that did not work an d I had to put that line.

    I will ask my customer if I can test that protected dir.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    I suggest using the supported method through cPanel after removing any custom changes you made to password protect the directory manually. Let us know if it does not work using the supported method.

    Thank you.
     
  7. DomineauX

    DomineauX Well-Known Member
    PartnerNOC

    Joined:
    Apr 12, 2003
    Messages:
    414
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I have run across this issue as well where after enabling password protection (via cPanel) on the web root, the site continues to be accessible without authentication. Only after adding "ErrorDocument 401 "Authorisation Required"" does the authentication become required.
     
  8. k2tec

    k2tec Well-Known Member

    Joined:
    Aug 26, 2011
    Messages:
    81
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Netherlands
    cPanel Access Level:
    Root Administrator
    Well I did not solve this problem and don't want to bother that customer anymore.
    This account I have to run with ErrorDocument 401 "Authorisation Required"
    All other accounts I can create it the normal cpanel way.
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Feel free to open a support ticket if you can reproduce this issue so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
Loading...

Share This Page