I have include "content.php" that loads in "index.php". How do I redirect the include to load into "index.php" when user requests direct URL access to "content.php"?
3 Answers
You can set a constant in your index.php before your include content.php; then in content.php check if it's defined. If not redirect to index.php. Example:
<?php // index.php
define('IN_APP', true);
include 'content.php';
?>
<?php // content.php
if(!defined('IN_APP')){
header('Location: index.php')
}
?>