PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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:
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));
}
}
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?
im aware of these but these domains are not hosted on any server we have control over. We just use the godaddy name servers and keep everything there and they do the 301 redirect for us, we don't do it. I suppose we could go through and put them on our server but I would rather not do all that work so is there an easier way to do this?