简体   繁体   English

PHP头重定向在IE 8中不起作用

[英]PHP header redirect doesn't work in IE 8

I'm using in redirecting by header(Location : 'http://..' ) command in PHP. 我正在使用PHP中的header(Location:'http:// ..')命令重定向。 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. 它在FireFox和Chrome中工作,但在IE 8中没有。我收到错误:“Internet Explorer无法显示网页”,尽管该页面确实存在。

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. 谢谢,尼姆罗德。

The PHP manual says: PHP手册说:

HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. HTTP / 1.1需要绝对URI作为»Location:包括方案,主机名和绝对路径的参数,但某些客户端接受相对URI。 You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself: 您通常可以使用$ _SERVER ['HTTP_HOST'],$ _SERVER ['PHP_SELF']和dirname()自己创建一个相对的URI:

<?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... 我认为IE8是其中一个浏览器......

也许您还需要将HTTP状态代码设置为3xx之一

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM