Redirect after php script executes
I've been reading about redirects on php.net and my question is, would this code as the last line of my php file do it?
// 307 Temporary Redirect
After reading more, I see my path must be like this:
Location header MUST be absolute uri with scheme, domain, port, path, etc.
But where do I place the code?
good: header("Location: http://www.example.com/something.php?a=1");
The main thing is that there can have been no output (even white-space not within your <?php tags) before the call to header(). Also, if you're using sessions, I find it good to do session_write_close() before you "get out of Dodge". I'll also exit right after it, if there's any code following it that should not be executed. So...
// lots of amazing PHP stuff with no echo/print stuff
// rest of page...
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks NogDog. Let's call this one closed.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread