You are here: Re: [PHP] No redirect with header() « PHP « IT news, forums, messages
Re: [PHP] No redirect with header()

Posted by Paul Waring on 10/20/91 11:29

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация