Re: No redirect with header()
| From: | Paul Waring | Date: | Sun, 16 Oct 2005 15:11:31 +0000 |
| Subject: | Re: No redirect with header() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224198@lists.php.net to get a copy of this message | ||
On Sun, Oct 16, 2005 at 05:04:09PM +0200, Dotan Cohen wrote:
> header ("Location: ".$url);
> ?>
>
> Does this seem like it should work? It doesn't. What is the correct
> syntax for these things?
That code should work, and the example on your site seems to work for
me. The only thing you should make sure is that $url is an absolute URL,
even if you're redirecting within your own site (e.g. you shouldn't use
../lyrics/ or /lyrics/) - you may be able to get away without doing this
but it's not the "correct" way to do things.
You may want to change your code to this:
header("Location: $url"); // no point in concatenating since double
quotes will interpolate the value of $url anyway
exit();
I can't remember why, but calling the exit(); function fixed a problem I
was having a while back when I was being sent to the right URL but the
old one was staying in my browser address bar.
Paul
--
Rogue Tory
http://www.roguetory.org.uk