Suppose you have 2 php files, say base.php and included.php included.php is included in, base.php. So you dont want included.php has been called directly from url. So in such a case, the solution is ######### #base.php ######### <?php define ("ACCESS",1); #defining a constant include ('included.php'); ?> ############# #included.php ############# <?php if(!defined("ACCESS")): #checking the constant die ('Direct call is restricted"; endif; echo "I am included"; ?>