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?

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();