2011-09-11 47 views
0

我正在使用PHP中的header(位置:'http:// ..')命令重定向。 它在FireFox和Chrome中工作,但不在IE 8中。 我收到错误: “Internet Explorer无法显示网页” 而且这是虽然页面确实存在。PHP标头重定向在IE 8中不起作用

可能是什么原因呢?

重定向功能:

function redirect($url, $statusCode = 303) { 
    header('Location: ' . $url, true, $statusCode); 
    die(); 
} 

召唤:

redirect("/page.php"); 

感谢, 尼姆罗德。

+1

显示验证码,如果可能,请输入网址 –

+0

您是否可以使用足够小的一段代码来发布并显示我们? –

+0

尝试标题('Location:'。url);出口; –

回答

0

也许你还需要将HTTP状态代码设置为3XX

+2

'header(“location:'does that that –

+0

status status is defined as 303. – Nimi

+0

@nimi - you right。Thinking of a different language than PHP。 –

2

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. 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; 
?> 

我觉得IE8是这些浏览器的一个...

+0

我试过了,但没有帮助。错误代码: – Nimi

+0

你认为可能是什么? – Nimi

+0

你是否尝试直接在IE8中访问该页面?PHP重定向你后地址栏中显示的是哪个url? – Ofir