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 http://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.
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.
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.
Edited for further explanation
Assuming you are using php, you generate the link at runtime. Here is some code I whipped up.
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