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?GpiiYMZAdL5e
domain.com/redir.php?YdcN6eDAj6xB
domain.com/redir.php?YdcN6eDAj6xB

then you go to (aol.com)


and
domain.com/redir.php?thzNda7aefMo
domain.com/redir.php?hXzRz35YszHA
domain.com/redir.php?PMyU6VXBiMk8

then you go to (yahoo.com)

how can I do this?
LVL 1
XK8ERAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Beverley PortlockCommented:

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.
0
XK8ERAuthor Commented:
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
0
nplibCommented:
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=<?=base64_encode("http://www.google.ca")?>">Mystery Site</a>

to the public it would look something like this.
<a href="redir.php?r=aHR0cDovL3d3dy5nb29nbGUuY2E=">Myster Site</a>

then on your redir.php page



<?php
$redir = $_GET['r'];
herader("location:".base64_decode($redir));
?>

Open in new window

0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

XK8ERAuthor Commented:
it cant have r=aHR0cDov

it has to be the code only
0
Beverley PortlockCommented:
OK, At the start of redir.php, put this code

<?php

if (isset($_SERVER['QUERY_STRING']) ) {
     switch( $_SERVER['QUERY_STRING']) {
          case "YdcN6eDAj6xB":
                       header ("Location: http://www.aol.com");
                       break;

          case "hXzRz35YszHA":
                       header ("Location: http://www.yahoo.com");
                       break;
     }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Beverley PortlockCommented:
Actually, it should have a default, just incase nothing is passed


<?php

if (isset($_SERVER['QUERY_STRING']) ) {
     switch( $_SERVER['QUERY_STRING']) {
          case "YdcN6eDAj6xB":
                       header ("Location: http://www.aol.com");
                       break;

          case "hXzRz35YszHA":
                       header ("Location: http://www.yahoo.com");
                       break;

          default:
                       break;
     }
}
0
nplibCommented:
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.

0
Beverley PortlockCommented:
OK - explain something to me. How you do relate YdcN6eDAj6xB to aol.com? What is the connection?
0
nplibCommented:
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")?>">Mystery Site</a>

to the public it would look something like this.
<a href="redir.php?aHR0cDovL3d3dy5nb29nbGUuY2E=">Myster Site</a>

then on your redir.php page
<?php
$redir = $_SERVER['QUERY_STRING'];
herader("location:".base64_decode($redir));
?>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.