Maybe something verbose like this:
/mydir/test.php
if (ereg("mydir",$PATH_INFO) AND $have_header =="") {
header("location: header.php?frompage=$PATH_INFO");
}
/header.php
L O A D W H A T E V E R Y O U N E E D H H E R E
header("location: $frompage?have_header=yes");
I hope this all makes sense.
You enter the URL /mydir/test.php; the header should be loaded first because it's in "mydir"; then redirect to header.php, and tell header.php where we come from; load header.php and redirect back to where we came from and add a querystring ($have_header="yes") so that it doesn't loop in infinity.
What do you want from header.php?