Shabat Closer
Tuesday, February 5, 2013
PHP - redirect function
function redirect($url)
{
if (strpos($url,"http://")===false){
$url = "http://".$_SERVER["HTTP_HOST"]. preg_replace('#^\/?(.*?)\/?$#', '/\1', trim($url));
}
// Redirect via an HTML form for PITA webservers
if (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')))
{
header('Refresh: 0; URL=' . $url);
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' .
$url . '">
<title>Redirect</title></head><body><div align="center">If your browser does not support meta redirection please click
<a href="' . $url . '">HERE</a>
to be redirected</div></body></html>';
exit;
}
// Behave as per HTTP/1.1 spec for others
header('Location: ' . $url);
exit;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment