Typo domain redirection
Posted: Thu Nov 29, 2007 5:34 am
My company has a big list of typo domains that we just have a 301 redirect to our actual website. My boss wants to log all of the cases where someone actually gets sent to us because of a typo domain so I setup this:
but this does not work because the redirect is not saved as the $_SERVER['HTTP_REFERER'], its not anywhere. How can I get to know if the users got to our site via one of our other domains?
Code: Select all
function check_for_domain_confusion()
{
$domains = array(
//huge list of domains, all in uppercase
);
$referrer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false);
if (false == $referrer)
{
return;
}
$url = parse_url($referrer);
if (in_array(strtoupper($url['host']), $domains))
{
$sql = '
INSERT INTO
rb_domain_misspellings
(
domain, time, full_url
)
VALUES
(
"'.mysql_real_escape_string($url['host']).'",
"'.time().'"
"'.mysql_real_escape_string($referrer).'"
)
';
$query = mysql_query($sql) or die(trigger_error('Bad Query Function (check_for_domain_confusion) Line ('.__LINE__.'): <br /><br /><pre>'.$sql.'</pre>', E_USER_ERROR));
}
}