sorry to revive an old thread but i found a (very obvious) solution to this that may help someone else:
in the index.php frameset tags do something like this:
<frame src="main.php?page=<?= $page ?>&index=true">
then at the top of main.php:
if (!isset($_GET['index'])) {header('location: index.php?page=' . $page);}
this way if a user goes directly to main.php (without going through the index.php frameset) the $_GET['index'] variable won't be set and they will be redirected. hope this helps someone.