Typo domain redirection

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!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Typo domain redirection

Post by shiznatix »

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:

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));
	}
}
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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Are all those typo domains handled by one server? Do you have access to the webserver's access log?
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

What is your redirect?

you could redirect using http://gotooriginaldomain.com/index.php?typodomain=blah

Code: Select all

<?
Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: http://www.new-url.com/index.php?typodomain=\"$_SERVER['HTTP_HOST']\"" ); 
?>
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

We have the domains on godaddy and we use their name servers and have it forwarded to our domain using a 301 redirect.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

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?
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

In the godaddy control panel where you type the redirect, can you not put for example.

ebay.co.uk is the main domain

eby.co.uk is a typo


Code: Select all

http://www.ebay.co.uk/index.php?typo=eby.co.uk");
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

ahha i see an option that i missed before! ok waiting for the domain to finish its thing then hopefully all will work well.
Post Reply