protect directory password

k2tec

Well-Known Member
Aug 26, 2011
104
5
68
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
 

k2tec

Well-Known Member
Aug 26, 2011
104
5
68
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
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.
 

k2tec

Well-Known Member
Aug 26, 2011
104
5
68
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
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.
 

DomineauX

Well-Known Member
PartnerNOC
Apr 12, 2003
429
11
168
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
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.
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.