Page 1 of 1

PHP Page Redirection

Posted: Fri Jan 29, 2010 5:39 pm
by noah_xumin
Hi there,

I have some two pages like http://www.domain.com/index.php?p=123 http://www.domain.com/index.php?p=456 . Is there anyway that I can set the page redirection so that when people visit http://www.domain.com/index.php?p=123 page, this page will be redirected to http://www.google.com and when people visit http://www.domain.com/index.php?p=456 page, this page will be redirected to http://www.yahoo.com ?

Thank you very much,

Noah

Re: PHP Page Redirection

Posted: Fri Jan 29, 2010 5:45 pm
by jazz090

Code: Select all

<?php
$p = $_GET['p'];
if ($p == 123){
    header('Location: http://www.google.com');
}
else if ($p == 456){
   header('Location: http://www.yahoo.com');
}
?>

Re: PHP Page Redirection

Posted: Fri Jan 29, 2010 6:11 pm
by requinix
Don't forget to put an exit; or die; after the header() - otherwise the redirection happens after PHP has processed the entire script.

Re: PHP Page Redirection

Posted: Mon Feb 01, 2010 9:35 am
by noah_xumin
Thank you guys! Really appreciated it! It works like charm!