|
|
function redirect($url) {
$protocol = $_SERVER['HTTPS'] == 'off' ? 'http://' : 'https://';
$hostspec = $_SERVER['SERVER_NAME'];
$dir_name = str_replace('\\', '/', dirname($_SERVER['PHP_SELF']));
if ($dir_name != '/') $dir_name .= '/';
if ($url{0} == '/') $redirect = $protocol . $hostspec . $url;
elseif (strstr($url, '://')) $redirect = $url;
else $redirect = $protocol . $hostspec . $dir_name . $url;
header("Location: $redirect");
exit;
}
//本函数适合于一般的地址转换! |
|