PHP Samples, Code & Tips

Thursday, December 08, 2005

Protecting important files from visitors to your website.

Choose a hosting service that has a writable base directory, with a web root folder underneath it.

eg:
/home/yoursite/ <--base directory
/home/yoursite/public_html/ <-- web root

I store files that I want to control access to, below my web root folder. An example might be storing fonts that you use with the GD Library (an image library - see http://www.php.net/image) in /home/yoursite/fonts/ to protect fonts you have purchased from being stolen.

You should keep in mind other people using the same shared hosting folder can have access rights to this directory, so use chmod to make sure you are the only user who can access the folder.