重定向用户,如果他们提交URL缩短器


Re-directing a user if they submit a URL shortener

如果$displayurl等于位,我试图重定向用户。ly,咕。Gl,或猫头鹰。这行不通。下面的IF语句有什么问题吗?

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

你必须使用以下代码:

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