doudong7256 2013-02-20 06:06
浏览 46
已采纳

php标头重定向无法正常工作

So, I consolidated various php login files from here into one file. to consolidate it to one file, I append the url, and do different things based off of what is appended.

This works locally but not on my remote server.

Anyway...

At the top of my 'consolidated' file I have

session_start();

This is the only time I have a session_start(). The rest of my post.php code looks like this:

if(isset($_GET['app1'])){
...do stuff
header("location:post.php?app2");
    exit();
}
if(isset($_GET['app2'])){
...do other stuff
header("location:post.php?app3");
    exit();
}

Locally, if I start at post.php?app1, it will go to post.php?app2 and work fine, but on the remote server it just gets stuck (no redirect). Does anyone know why?

  • 写回答

1条回答 默认 最新

  • duanhegn231318 2013-02-20 06:19
    关注

    maybe these happen because there was a code that provide an output before trying to redirect. try add buffer function in your 'consolidated'file.

    ob_start();
    session_start();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?