Reputation: 309
My website is coded using PHP. Library files are stored in a directory called 'library'.
Within my php I access the library files by
require_once('library/myfile.php.inc');
However, if the user types in
http://www.example.com/library/myfile.php.inc
They are able to download the source code. How can I prevent this?
Upvotes: 0
Views: 381
Reputation: 211
Create .htaccess file under root/library/.htaccess and write the following
<FilesMatch ".*">
Order Allow,Deny
Deny from All
</FilesMatch>
Upvotes: 1