if i understand what you want correctly, you could use sessions pretty effectively.
this would go in your main page, and only in your main page
session_start();
$_SESSION['visited_main'] = true;
this would go in all other pages
session_start();
if (!isset($_SESSION['visited_main'])) {
header('Location: http://example.org/mainpage.php');
}