Re: No redirect with header()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux