Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

header redirect not working

8:33 pm on Mar 15, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0

I'm guessing this a configurtion on my windows server but I'm getting the Warning: Cannot modify header information - headers already sent by error trying to redirect. I literally have this in the file
<?php header("Location: [google.com...] ?>
I double checked to make sure there was no lines or spaces before it. Does anyone know why this isn't working?
running a win 2k8 r2 server
10:56 pm on Mar 15, 2013 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 16, 2008
posts: 136
votes: 0

This means that you may have something else before the header or another header redirect somewhere in your code. Do you include any other file that might have a header redirect too?

[edited by: skoff at 11:02 pm (utc) on Mar 15, 2013]

10:59 pm on Mar 15, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
votes: 0

HI there Andrewsmd,

Aaah, this old chestnut! This error is generated only when information has already been sent to render on the webpage, if there is a redirect used, it should be the ONLY instruction after the <?php NO HTML, else this error is generated.

Read this article [php.net]

It's also good practice for you to have this sort of thing done too:-

if($something = true){
header("location: this.site.com");
header("location: that.site.com");

Having the exit there ensures that NOTHING else down stream gets actioned, therefore nothing erroneous gets sent to the screen - this ensures that the header is the only code parsed.

Hope as this helps you out.. Also, you're missing the ; in your example ;)