Password protection directory

danrussell

Well-Known Member
Nov 5, 2014
61
4
58
cPanel Access Level
Root Administrator
Hi,

I want to protect one of folder which is at location httpdocs with password protection
I have tried the method of password protection using .htpassword option but it wont ask for authentication while accessing the url.
Can you please let me know what I am doing wrong.

I have used following method:

Created .htaccess file under /usr/local/apche/httpdc/Myfolder/ and added following rules into it.


AuthName " restricted access"
AuthType Basic
AuthUserFile /usr/local/apche/httpdoc/Myfolder/.htpasswd

require user admin



created user using .htpassword file creator and placed the .htpassword file into other location so that it will not accessible via browser for security purpose.

Can you please let me know what I am doing wrong.

Thanks,
Dan.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,226
463
Hello,

Is this a cPanel server? If so, is there any reason your accounts are not stored in the /home/$username directory? Have you tried using the "Password Protect" feature in cPanel? Or, is this for a system directory that you want accessible to the public?

Thank you.
 

danrussell

Well-Known Member
Nov 5, 2014
61
4
58
cPanel Access Level
Root Administrator
Hi ,

I am able to achieve the password protection by doing slight modification in httpd.conf as below:

I have created below entry and replaced "AllowOverride None" by "AllowOverride All":
===========
<Directory "/usr/local/apache/htdocs/mrtg">
Options All
AllowOverride All
Require all granted
</Directory>
===========

Till now no issues with the websites after I restarted the httpd service. Please let me know will it make any other effects with the above changes.

Regards.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,226
463
  • Like
Reactions: danrussell