开发者

PHP header redirect not working on production, blank page

I am about to throw the towel in. Can somebody help me figure this out. On my local dev server this bit of PHP works fine, its just doing a redirect by constructing a url out of some variables. So I get redirected to this page as expected.

$status = "0"; //unsubscribed
header('Location:http://www.skandium.com/manage-your-mailing-list.asp?status='.$status);
die();

On the production server I just get a blank page. I know the PHP page itself is working because all other things that happen upto and before this line work fine. I can replace this line with a simple echo and can see the URL is correct also.

Other details:

  • Hosted on a windows box (dev is also windows)
  • same PHP version running via FASTCGI

EDIT: the plot thickens

The following code on its own i开发者_StackOverflow社区n a new page works fine on production. Still doesn't explain why the above code works locally and not on production. All I seemed to have ruled out is that the header redirect statement by itself is not the culprit.

<?php 

//test.php

//prevent page caching
header("Cache-Control: no-cache"); 
header("Expires: -1");

$status = "0"; //unsubscribed

header('Location:http://www.abc.com/manage-your-mailing-list.php?status='.$status);
die();

?>


Make sure there is no whitespace before php tag


A few thing you can try is:

  • Check if headers_sent() is true before sending the redirect header
  • Set error_reporting(E_ALL) and ini_set('display_errors', 1)
  • Use firebug to check what (if any) headers are being sent to the browser


Try this..

header('Location: http://www.abc.com/manage-your-mailing-list.php?status='.$status)

I just add a space between colon(:) and the url.. I don't know this happened to others, but sometimes this kind of things happened to me and sometime this works for whatever reasons..

Also, have you tried relative path? or at other pages, i mean does "header location" works on other places? or it happens on this script only?


Is the file UTF-8 encoded? Any output can prevent the code to be executed, including a BOM. Maybe the encoding was not explicitly set, but your dev machine assumed UTF-8 (and ignored the mark) while your production server didn't.


None of these worked.

I ended up echoing a meta redirect.

I could also have echoed a javascript location.replace

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜