John
John

Reputation: 4944

Re-directing a user if they submit a URL shortener

I'm trying to re-direct a user if $displayurl is equal to bit.ly, goo.gl, or owl.ly. It's not working. Is there anything wrong with the IF statement below?

$site1 = 'http://' . $cleanurl;

$displayurl = parse_url($site1, PHP_URL_HOST);


if ($displayurl == array(bit.ly, goo.gl, owl.ly))
{

   session_write_close();
   header("Location:http://www.domain.com/directory/file.php");
   exit;

}

Upvotes: 2

Views: 62

Answers (1)

Book Of Zeus
Book Of Zeus

Reputation: 49877

you have to use this code:

$domain = array("bit.ly", "goo.gl", "owl.ly");
if (in_array($displayurl, $domain)) {
   session_write_close();
   header("Location:http://www.domain.com/directory/file.php");
   exit;
}

Upvotes: 5

Related Questions