Reputation: 599
I'm using in redirecting by header(Location : 'http://..' ) command in PHP. It's working in FireFox and Chrome but not in IE 8. I'm getting the error: "Internet Explorer cannot display the webpage" and it's though the page is indeed existed.
What may be the reason for it?
The redirect function:
function redirect($url, $statusCode = 303) {
header('Location: ' . $url, true, $statusCode);
die();
}
The call:
redirect("/page.php");
Thanks, Nimrod.
Upvotes: 0
Views: 3168
Reputation: 415
The PHP manual says:
HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself:
<?php
/* Redirect to a different page in the current directory that was requested */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>
I think IE8 is one of those browsers...
Upvotes: 2