|
Posted by Rik on 08/10/07 18:30
On Fri, 10 Aug 2007 20:07:03 +0200, amygdala <noreply@noreply.com> wrote=
:
> First off: sorry about the empty posts people. I pushed accidentally =
> pushed
> the send button (twice :-S ).
>
> "amygdala" <noreply@noreply.com> schreef in bericht
> news:46bc9d79$0$25487$9a622dc7@news.kpnplanet.nl...
>>
>
> <snip (very useful info nonetheless :-) >
>
>> $target =3D 'http://www.example.com';
>> header("Location: $target");
>> echo 'You're be redirected to '.$target.'. Click <a
>> href=3D"'.$target.'">here</a> if it doesn't work';
>> exit; //<-----IMPORTANT!
>>
>
> Well whatta you know!! As soon as I put this suggestion of yours after=
=
> the
> header("Location: $target"); it works! And mind you, not necessarily t=
he
> exit() part, but the echo part!! How strange is that? I'm loosing all =
=
> sense
> of logic on this one.
>
> Could it be that Opera needs some kind of body content after a =
> redirection
> header? Or could it perhaps be that Opera indeed thinks that it should=
> redirect back to the login page again, since it is redirected to a pag=
e,
> that redirected to the login page in the first place. lol
Possiblity 1:
Opera -> Tools -> preferences -> Advanced -> Network -> Enable Automatic=
=
Redirection.
It's enabled by default, but can be disabled for whatever purpose. All t=
he =
more reason why a header redirect should be accompanied by some =
information one is redirected, and a script should die()/exit() after th=
at.
Possibility 2:
Opera get's the redirect, but still has the page with the same URL in =
cache, so decides to use that one. Set some header and/or html informati=
on =
these pages should not be cached.
Possibility 3:
The script isn't terminated after the first header-redirect, continues t=
o =
run, and effectively changes the redirect by a second header() call. =
Putting an echo directly after it will force the headers to be sent, so =
=
they cannot be replaced anymore, resulting in the first one being the on=
ly =
one, and thus the one obeyed by the browser. Another example why one =
should die()/exit() after a redirect.
<?php
//this will offcourse end in /second.html
header('Location: /first.html');
header('Location: /second.html');
?>
<?php
//this will end in /first.html
header('Location: /first.html');
flush();
header('Location: /second.html');
?>
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|