views:

302

answers:

3

I work for company that links out to partners through a third party website that tracks them. So for example on our site there will be an outgoing link something like this (names changed to protect my work):

<a href="link.php?link=chuckecheese">check it out kids!</a>

if you go into link.php, you see I define the link there:

$outlink['chuckecheese'] = "http://partners.linktrackingisprettycool.com/x/212/CD1/$STAMP";

$STAMP is a timestamp and is replaced with, say, "12-25-09-1200" for noon on christmas.

When a user clicks on this link, he goes to www.chuckecheese.com

This all works fine, but it isn't as good for SEO purposes as it could be. I want to make it so that search engines will see it as a link to chuckecheese.com, which which helps our partners' pageranks and is more honest.

I'm in .htaccess trying to make up rewrite rules but I'm confused and don't know exactly how it's done. I tried:

RewriteRule http://www.chuckecheese.com$ link.php?link=chuckecheese$ [QSA]

But this doesn't seem to work. What should I try next?

Thanks in advance for any help. You guys on here are always awesome and I appreciate the part that the good people at stack overflow play in me remaining employed.

+2  A: 

You can't use a rewrite rule to redirect the user for this. The request has to be one processed by your webserver.

You might try doing some javascript to achieve this. so the href is to chuckecheese, but onclick, you change the document.location to what you really want to do.

Edited question for bounty

What you could do is pre-process your links based on the user agent of the browser. So when the user-agent is googlebot (one of the below strings), You display the real url of http://www.chuckecheese.com.

Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Googlebot/2.1 (+http://www.googlebot.com/bot.html)
Googlebot/2.1 (+http://www.google.com/bot.html)

When the URL is not googlebot, you display the link that does traffic analytics.

You can find a list of user agents at the following URLs:

If googlebot isn't showing the correct user-agent (or it changes in the future) google recommends you do a reverse look up against the IP address. This will be a small performance hit.

You can verify that a bot accessing your server really is Googlebot by using a reverse DNS look up, verifying that the name is in the googlebot.com domain, and then doing a forward DNS look up using that googlebot name. This is useful if you're concerned that spammers or other troublemakers are accessing your site while claiming to be Googlebot. -Google

Edited for further explanation Assuming you are using php, you generate the link at runtime. Here is some code I whipped up.

function getRealURL($url)
{
 // adjust this regex to match the pattern of your traffic analysis urls
 ereg("link=(.+)$",$url,$matches);
 if ($matches[1])
 {
  // adjust this so the urls come out correctly
  return "http://www.".$matches[1].".com";
 }
 else 
 {
  return $url;
 }
}
function isGoogle()
{
 switch ($_SERVER['HTTP_USER_AGENT'])
 {
  case 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)':
  case 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)':
  case 'Googlebot/2.1 (+http://www.google.com/bot.html)':
   return true;
  default:
   return false;
 }  
}
function showlink($url)
{
 $trafficAnalysisUrl = getRealURL($url);

 if (isGoogle())
 {
  return $url;
 }
 else
 {
  return $trafficAnalysisUrl;
 }
}


<html>
...
Come eat pizza at <a href='<?=showLink("link.php?link=chuckecheese")?>'>chuck e cheese!</a>
...
</html>

I doubt google would care about something like this since both links go to the same place. But check the TOS to be sure. http://www.google.com/accounts/TOS

Byron Whitlock
Yeah I thought of that but really don't want to use javascript, I thought there was a way I could use 301s to do it.
pg
Hey this is a really good idea. I will try this.
pg
But how do I change which link is displayed?
pg
And will this get me in trouble with google? It seems like it's willfully misdirecting them, even if my intentions are good.
pg
Thanks and thanks for sticking with the chuck e cheese theme all the way to the end.
pg
+2  A: 

An assumption of yours is not good. You say:

I want to make it so that search engines will see it as a link to chuckecheese.com, which helps our score when people search for chuck e cheese because we'll be seen as linking right to them.

If this really helped SEO wise, every body would spam link all great sites just to get SEO pagerank and the game would just be too easy. The beneficiary of a link is the recipient page/site, not the sender.

allesklar
You cannot increase your page rank just by linking to other pages. The other pages need to link to you to increase your page rank!
Gumbo
+1 Very true, good point.
Byron Whitlock
I feel dumb for having said this. Yes if pagerank worked this way, I don't think google would be very useful. However, I've heard there s some pagerank benefit to be gained by not being totally closed off, which is how our site looks now.
pg
A: 

Hey PG... linking out to other websites will not give you any further PageRank just as having your ads in Adwords appearing on a thousand other sites will not give you PageRank. And yes, your partners are being benefited by having you linked to them. And what about those benefits to be gain that you speak of from being open? From my understanding of what you have wrote, it is just another fancy redirect. Google knows that.