You are here: Re: php reidrects from one url to another « All PHP « IT news, forums, messages
Re: php reidrects from one url to another

Posted by Nospam on 05/22/06 23:45

"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:e4ss3g$m6c$1@netlx020.civ.utwente.nl...
> Nospam wrote:
> > I have a series of links on my site, and I want them once clicked to
> > be redirected to another site, I have heard that I could have a
> > redirection.php file and in it have my link1, link2, link3 etc
> > redirecting to different sites.
> >
> > Does anyone have an implementation example of the above
> > redirection.php, or an amended example?
>
> If you want them redirected to different sites, think carefully what your
> exact reason is. Often it's just plain better to give the link to the
actual
> url.
>
> Then again, if not, for example:
>
> <a href="./redirected.php?link=2">Link 2</a>
>
> redirected.php:
> <?php
> $urls = array(1=>'http://example.com', 2 => 'http://www.php.net');
> header("Location: {$urls[$_GET['link']]}");
> ?>

I am a little confused as to the reason for http://example.com above, I take
it this means the site b4 redirection, if I was redirecting from
http://www.example.com/link1.html to http://www.php.net I take it
http://www.example.com/link1.html would replace http://example.com as above?
If was using more than one redirects would this be appropriate:
<?php
$urls = array(1=>'http://example.com', 2 => 'http://www.php.net');
header("Location: {$urls[$_GET['link']]}");
?>
<?php
$urls = array(2=>'http://example.com', 2 => 'http://www.php1.net');
header("Location: {$urls[$_GET['link']]}");
?>
It seems only the last one works


> Make sure you don't output ANYTHING to the client before a header(), not
> even a blank line.
>
> Grtz,
> --
> Rik Wasmus
>
>

 

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

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