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
PHP Page Redirection
Moderator: General Moderators
Re: PHP Page Redirection
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
Don't forget to put an exit; or die; after the header() - otherwise the redirection happens after PHP has processed the entire script.
-
noah_xumin
- Forum Newbie
- Posts: 3
- Joined: Wed Dec 23, 2009 10:08 am
Re: PHP Page Redirection
Thank you guys! Really appreciated it! It works like charm!