I have certain files like header.php and footer.php. I would like to disable these files from being directly requested from the browser address bar.
If I have include 'file.php' in the code, then it should be included, but if it’s directly requested, I don’t want it to be shown since it serves no purpose. Is it possible?
Thanks in advance 🙂
You can do any of these things, in order of desirability (from “good” to “it kind of works”):
/somepath/example.com/htdocs/maps tohttp://example.com/:/somepath/example.com/htdocs/index.php/somepath/example.com/includes/header.php/somepath/example.com/includes/footer.phpindex.php:
<Files (header|footer).php>Deny from all</Files>index.php:
<?php define('INCLUDED_FROM_MAIN_FILE_EXAMPLE_COM',true) ?>header.php:
<?php if (!defined('INCLUDED_FROM_MAIN_FILE_EXAMPLE_COM')) { die(); }