Header Redirection .. what can stop it working?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Header Redirection .. what can stop it working?

Post by onion2k »

On a lot of my sites I use:

Code: Select all

header("Location: nextpage.php");
to move users from one page to another. It's great, For 99.9% of users it works fine. However, very occasionally a user will complain that their browser "hangs" at the point I would expect them to be forwarded to the next page. What's up with that? What can stop it forwarding?

Things to consider:

1. It works for most people therefore it's very unlikely to be a code issue.
2. I definitely haven't outputted anything prior to sending the header.
3. No matter what I try I cannot replicate the problem.
4. I know I should be using a fully qualified URL, but I don't believe that to be the issue.
5. It's not a problem with a specific browser, some users get the problem with IE.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Header Redirection .. what can stop it working?

Post by Benjamin »

onion2k wrote: 4. I know I should be using a fully qualified URL, but I don't believe that to be the issue.
Thats gotta be it. Maybe you can replace it with a full url on a few pages and see if the problem goes away on those pages. I can't think of anything else it could be.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

iirc, some browsers (or an option within most browsers when set to off) do not follow header redirects.

meta-tag redirects should work however.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Try placing exit() after the call....

It may be an idea to fallback with a meta redirect too like Jenk says, although I've never had to do that. Opera used to refuse to follow my reidrects when I had pages redirecting to other pages which made new redirects (not infinitely, just multiple hops).

EDIT | Is this a T&D question? :?: 8)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

d11wtq wrote:It may be an idea to fallback with a meta redirect too like Jenk says, although I've never had to do that. Opera used to refuse to follow my reidrects when I had pages redirecting to other pages which made new redirects (not infinitely, just multiple hops).
Ah. AH. Now that might explain it. I am doing that in a few places.
d11wtq wrote:EDIT | Is this a T&D question? :?: 8)
It's not really a 'PHP - Code' question or a 'Clientside' question. So yes.
Post Reply