<?
function location ($url =NULL){
$location =NULL;
if(! $url) {
$url = $_server['php_self'];
}
ElseIf (substr ($url,0,1) =='?') {
$url = $_server['php_self'] . $url;
}
if(Substr ($url,0,7) ==='/ http'or substr ($url,0,8) ==='https://') {
$location = $url;
}
Else{
$port =NULL;
if($_server['Server_port'] ==443) {
$protocol ='https://';
}
Else{
$protocol ='/ http';
$checkPoint =explode (":", $_server['Http_host']);
if(count ($checkPoint) = =0) {
$port =':'. $_server['Server_port'];
}
}
$dir = DirName ($_server['Script_name']);
if($dir = = ="/") {
$dir ="";
}
if(Substr ($url,0,2) ==='./') {
if($dir) {
$location = $protocol. $_server['Http_host'] . $port.'/'. $dir.'/'. BaseName ($url);
}
Else{
$location = $protocol. $_server['Http_host'] . $port.'/'. BaseName ($url);
}
}
ElseIf (substr ($url,0,1) ==="/") {
$location = $protocol. $_server['Http_host'] . $port. $url;
}
Else{
$location = $protocol. $_server['Http_host'] . $port. $dir.'/'. $url;
}
}
Header"Location : $location");
Exit ();
}
?>
//Skip to Baidu homepage
Location ('http://www.baidu.com');
Simple and flexible PHP page jump function