/    Sign up×
Community /Pin to ProfileBookmark

Redirect with "header" after there is some output on page

I am kind of confused, I built this site on one server and even though there was output coming from the pages, whenever I threw in a header redirect it would redirect to the new page regardless. I moved it to a new server and the redirects stopped working… did a little research and now realize they apparently aren’t supposed to ever work after the page has some output?

Makes me wonder why they worked on the first server.

Anyway… is there a way around this? Or another way to redirect mid-page? There HAS to be, right? I really don’t want to have to go back and redesign all of this stuff, especially considering that the current scope of what is going on pretty much requires the ability to redirect after output.

Oh, and I can’t do client redirects because I need to pass PHP variables in the header sometimes.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayMay 14.2008 — Could try something like:

[code=php]
ob_start();
header("location:" . $_SERVER['SERVER_URL'] . "NewPage.php");
ob_clean();
[/code]
Copy linkTweet thisAlerts:
@xvszeroauthorMay 14.2008 — Hmm, nah didn't work.

It's very confusing to me why this worked on my old server and not the new one. Not to mention I used to always use ASP redirects mid-page and never had a problem there either.
×

Success!

Help @xvszero spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...