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 Rik on 05/23/06 00:02

Nospam wrote:
> "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.
>> <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?

Euhm, no. Also, please don't use "b4" and the like, I'm not a native
speaker, and correctly spelling words instead of this 'lingo' really helps a
lot in reading. At first, I was wondering what kind of encoding or method b4
possibly could be.

$urls is just an array of the different sites you want the visitor to be
redirected to, hence example.com :-). The keys of the arrays is how you find
them using the get variable

> <?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']]}");

I think you mean:
$urls = array(2=>'http://www.php.net', 2 => 'http://www.php1.net');

Where redirected.php?link=1 wil redirect to 'http://www.php.net',
redirected.php?link=2 wil redirect to 'http://www.php1.net'.

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

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