I am using apache server. Is there a way to prevent users from accessing my include files directly ? But only allow the server the access to those ?
3 Answers
Another way is to have the include files outside of the directory the site is served from. For example:
/ includes/somefile.php http/index.php So the Web site is served from http/, but includes are outside of that directory, meaning no one can access them directly from a Web browser, but your scripts can include them like this:
<?php require_once '../includes/somefile.php'; [...]