How do I lock files in my public_html directory?

The best way of doing this is to use a combination of a .htaccess file and a .htpasswd in the directory you would like to lock.

An easy way to generate these 2 files can be found here.

An example .htaccess file:

********Start***********
AuthName “Restricted Stuff”
AuthType Basic
AuthUserFile /home/YOUR_USERNAME/Path to .htpasswd file

require valid-user
********End***********
An example .htpasswd file:

************START**************

username:jdui43JIIO

************END*************
Note that you shouldn’t have the .htpasswd file in a web accessible folder.

Once you have made both files you need to change the permissions using:

chmod 655 .htaccess .htpasswd

Posted in: Websites and pages