This script is intended to redirect people back to the root application when manually browsing to hidden application folders. i.e.
/inc/ should never show an index, so we install an index.html / index.php. This script will redirect people back to ./ no matter what the path.
<?php // No matter where you are, always redirect back to root $r = ''; $d = (count(explode('/', dirname($_SERVER['SCRIPT_NAME']))) -1); for($l = 1; $l <= $d; $l++){$r .= '../';} header('location:'.$r); ?>
Tagged: any, application, back, Count, directory, dirs, from, good, include, levels, path, PHP, redirect, root, secure, security, Server, The, to, Using, way, Web, within