View Full Version : redirect specific incoming links using PHP?

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

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:

$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);