...

View Full Version : redirect specific incoming links using PHP?



student101
03-04-2012, 10:09 AM
How would I be able to redirect all these incoming links to root?

http://www.example.com/home.php?pg=3
(http://www.example.com/home.php?pg=3)http://www.example.com/home.php?pg=4
(http://www.example.com/home.php?pg=3)http://www.example.com/home.php?pg=5
(http://www.example.com/home.php?pg=3)
this is exists for every incoming link home.php?pg=(number)

Do I need to check that the incoming link has the rule above then redirect to http://www.example.com/

Any ideas welcome.

I was thinking of a function that checks if the pg var is a num then redirect?


if (is_numeric($_GET['pg'])){
$redirectnum = is_numeric($_GET['pg'])
$redirect = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18);
if(in_array($redirectnum, $redirect)){
header ("Location: http://www.example.com/");
}
}


This seems to work:


<?php
$redirect = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,"anytextvartoo");
if( in_array($_GET['pg'], $redirect ) || in_array($_GET['blg'], $redirect ) ) {
header("Location: http://www.example.com", true, 301);
exit();
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum