Page 1 of 1

header("Location: ...") question

Posted: Tue Aug 03, 2004 11:37 am
by tylerdurden
I'm making heavy use of

Code: Select all

header("Location: $url");
calls on a website of mine and everything's working well.
Now a user contacted me to say that the redirections aren't working. I'm not sure if it's got anything to do with the "header("Location: $url");" code yet, but I think I'd ask the Forum members anyway if there are any known incompatibilities with this method of redirection?
I've tested it in most browsers without problems.

Thanks!

Posted: Tue Aug 03, 2004 11:41 am
by penguinboy
On some browsers you can disable redirection.

Posted: Tue Aug 03, 2004 11:41 am
by nigma
Maybe somewhere in your script $url gets the wrong url assigned to it? That would explain why the user is getting redirected to the wrong pages.

Posted: Tue Aug 03, 2004 11:48 am
by nigma
Penguinboy, where'd you find that out? I couldn't find too much on the topic.

Posted: Tue Aug 03, 2004 12:31 pm
by prov
The header function sends a response to the client, and it's up to the client (i.e. browser) to determine what to do with that directive. Just like if the PHP script echoed a response, for all we know the browser might interpret that to mean "crash now".

Headers are kind of tricky that way. I suggest, under your header function, you echo a link to the intended destination.

Posted: Tue Aug 03, 2004 12:35 pm
by nigma
Alright, thanks prov.

Posted: Tue Aug 03, 2004 2:09 pm
by d3ad1ysp0rk
Not quite. The header function is like anything other php function, it just tells the server to send the information from a different page instead of the original. The browser has nothing to do with it.
The problem is with your code/input, not the browser.

Posted: Tue Aug 03, 2004 2:17 pm
by burzvingion
LiLpunkSkateR wrote:Not quite. The header function is like anything other php function, it just tells the server to send the information from a different page instead of the original. The browser has nothing to do with it.
The problem is with your code/input, not the browser.
Incorrect. Try using cURL sometime on a page that uses a location header. Its up to the browser to get the new page. Some browsers have trouble if you dont use an absolute url, so make sure if you're dynamicly making urls to put $_SERVER['HTTP_HOST'] before the relative location

Posted: Wed Aug 04, 2004 10:51 am
by penguinboy
nigma wrote:Penguinboy, where'd you find that out? I couldn't find too much on the topic.
Just look in your browsers settings.
I use Opera, and it allows me to disable redirection.