Shared : Always redirect to root script.

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);
?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s