Perhaps this will help. I spent a little bit of time working on it, but I tried it out and it works. You will just have to modify parts of it to your liking. I tried to comment a little bit to help you out.
<?php
//Dragoneye_XP's Auto-Redirection Script (v1.0).
//This script should usually go at the beginning of the page.
if(!empty($_GET['go'])){
$thelink = $_GET['go'];
if(file_exists($thelink)){
include $thelink; //Example: If /pages/mypage.htm exists, then get and display it.
}else{
if(preg_match("/[\w]:\/\//",substr($thelink,0,8))==true){ //If we find a URL in the link (http://www.gooogle.com, etc)...
//Print the page to redirect you to the link.
//WARNING: DO NOT CHANGE THE LINE BELOW!
print <<<Redirect_To_Page
<!-- Redirect Page HTML -->
<html><head><META HTTP-EQUIV=Refresh CONTENT="5; URL=$thelink">
<title>Redirecting...</title>
</head><body><div align="center"><table border="1" style="border-collapse: collapse"><tr><td style="color: #000000; border: 3px outset #CCCCCC; background-color: #CCCCCC"><p align="center">
<b>You will be redirected to "<font color="#800000">$thelink</font>" <br>
in about five seconds.<br>
<font size="2">(if nothing happens, <a href="$thelink">click here</a>.)</font></b>
</td></tr><tr><td style="color: #000000; border: 1px outset #999999; background-color: #999999"><p align="center">
<a href="javascript:history.back()"><< Cancel</a>
</td></tr></table></div></body></html>
<!-- END Redirect Page HTML -->
Redirect_To_Page;
exit;
//WARNING: DO NOT CHANGE THE TWO LINES ABOVE THIS!
}else{
print <<<Page_Not_Found
<!-- Page Not Found HTML -->
<html><head><title>Error: Page Not Found</title></head><body><div align="center"><table border="1" id="table1" style="border-collapse: collapse"><tr><td style="color: #000000; border: 3px outset #CCCCCC; background-color: #CCCCCC"><p align="center">
<b>Sorry, I could not find any page named "<font color="#900000">$thelink</font>".</b>
</td></tr><tr><td style="color: #000000; border: 1px outset #999999; background-color: #999999"><p align="center">
<a href="javascript:history.back()"><< Go Back</a>
</td></tr></table></div></body></html>
<!-- END Page Not Found HTML -->
Page_Not_Found;
exit;
//WARNING: DO NOT CHANGE THE TWO LINES ABOVE THIS!
}
}
}
?>