How to Disallow Direct Access to a File with PHP

Just include this PHP code at the top of your include file.

<?php
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'includefilename.php' == basename($_SERVER['SCRIPT_FILENAME']))
	die ('Direct File Access Prohibited');
?>

Related posts:

  1. Get Post Slug in WordPress
  2. Send test emails with WampServer

Speak Your Mind

*