XK8ER
asked on
redirect to a different page
Hello there,
I have (redir.php) that when you go to it it redirect it to (google.com)
but I would like to add something like this to the code
domain.com/redir.php?GpiiY MZAdL5e
domain.com/redir.php?YdcN6 eDAj6xB
domain.com/redir.php?YdcN6 eDAj6xB
then you go to (aol.com)
and
domain.com/redir.php?thzNd a7aefMo
domain.com/redir.php?hXzRz 35YszHA
domain.com/redir.php?PMyU6 VXBiMk8
then you go to (yahoo.com)
how can I do this?
I have (redir.php) that when you go to it it redirect it to (google.com)
but I would like to add something like this to the code
domain.com/redir.php?GpiiY
domain.com/redir.php?YdcN6
domain.com/redir.php?YdcN6
then you go to (aol.com)
and
domain.com/redir.php?thzNd
domain.com/redir.php?hXzRz
domain.com/redir.php?PMyU6
then you go to (yahoo.com)
how can I do this?
ASKER
no i dont think you understood correctly..
if I ask for page (redir.php?hXzRz35YszHA) I want it to redirect me to yahoo
if I ask for page (redir.php?YdcN6eDAj6xB) I want it to redirect me to aol
if I ask for page (redir.php?hXzRz35YszHA) I want it to redirect me to yahoo
if I ask for page (redir.php?YdcN6eDAj6xB) I want it to redirect me to aol
how I would do it is like this.
Lets say you have a page with 1 link in it.
make the link like this
<a href="redir.php?r=<?=base6 4_encode(" http://www.google.ca")?>">Myst ery Site</a>
to the public it would look something like this.
<a href="redir.php?r=aHR0cDov L3d3dy5nb2 9nbGUuY2E= ">Myster Site</a>
then on your redir.php page
Lets say you have a page with 1 link in it.
make the link like this
<a href="redir.php?r=<?=base6
to the public it would look something like this.
<a href="redir.php?r=aHR0cDov
then on your redir.php page
<?php
$redir = $_GET['r'];
herader("location:".base64_decode($redir));
?>
ASKER
it cant have r=aHR0cDov
it has to be the code only
it has to be the code only
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually, it should have a default, just incase nothing is passed
<?php
if (isset($_SERVER['QUERY_STR ING']) ) {
switch( $_SERVER['QUERY_STRING']) {
case "YdcN6eDAj6xB":
header ("Location: http://www.aol.com");
break;
case "hXzRz35YszHA":
header ("Location: http://www.yahoo.com");
break;
default:
break;
}
}
<?php
if (isset($_SERVER['QUERY_STR
switch( $_SERVER['QUERY_STRING']) {
case "YdcN6eDAj6xB":
header ("Location: http://www.aol.com");
break;
case "hXzRz35YszHA":
header ("Location: http://www.yahoo.com");
break;
default:
break;
}
}
unfortunately that would only work if you know every link that might be added to the redir.php makes it very static and then pointless to have a redir page.
OK - explain something to me. How you do relate YdcN6eDAj6xB to aol.com? What is the connection?
with my example it uses base64_encode() and base64_decode() so when you create the url you encode the querystring in base64 and on the redir.php you decode it then you have link.
XK8ER:
to use my example without the r=fjasdf do it like this.
<a href="redir.php?<?=base64_ encode("http://www.google.ca") ?>">Myster y Site</a>
to the public it would look something like this.
<a href="redir.php?aHR0cDovL3 d3dy5nb29n bGUuY2E="> Myster Site</a>
then on your redir.php page
XK8ER:
to use my example without the r=fjasdf do it like this.
<a href="redir.php?<?=base64_
to the public it would look something like this.
<a href="redir.php?aHR0cDovL3
then on your redir.php page
<?php
$redir = $_SERVER['QUERY_STRING'];
herader("location:".base64_decode($redir));
?>
Have a code which you put in a variable (say) $extra = "YdcN6eDAj6xB";
Then
header("Location: http://domain.com/redir.php?$extra");
exit;
should do it.