in a.php
code:
<?
include('error.php');
// or insert your own error page in here
?>
in b.php
code:
<?
include('thepageyouwantthemtogoto.php');
?>
Or do you mean when they access a.php from
http://my_server.com/a.php its an error but when it is accessed from
http://my_server.com/b.php it runs the correct a.php page, if so you might wanna try $_SERVER['HTTP_REFERER']