Great for SEO: PHP redirect script, tip & question :)

by AprilK
5 replies
Ok, so I was browsing the net looking for a redirect script, I'm somewhat new to this. I wanted one that redirected, but still hid my affiliate link in the browser. The usual one that looks like this:

<?php
header('Location: aff link here');
?>

It cloaked my link, but my aff id still shows up on the affiliate site in the browser.

so I found a blog that gave an awesome redirect script that also blocks search engines from following your affiliate link and therefore it won't get burried in the "serps", (whatever the heck that means...lol). I just know it's so your site isn't "dubbed" as an affiliate site, which Google doesn't like.

anywho, I just need a little help on how to use it, what do i put where in the code? I understand how to make the php files and upload them along with the robot.txt file. Just need to know where to put the affiliate url and my website url. And wouldn't just putting a "no follow" thing for the robots work on all links?

Here's the blog post from crt tard, or if you prefer you can read it here:
Better Affiliate Link Cloaking for SEO | CTRtard.com - Internet Marketing with a Helmet
=====================================

Better Affiliate Link Cloaking for SEO
Posted by ctrtard on Nov 08, 2010


Not to be confused with referrer cloaking, cloaking affiliate links is typically done to present a nice looking URL to the user. The idea is, the savvier visitor might see a weird URL in the browser status bar and be less likely to click--so it's best to cloak the link. If you're using this technique for a landing page that you're driving paid traffic to, then one of the usual link cloaking methods is fine.

Cloaking affiliate links on a niche site or datafeed site that's relying on organic traffic is a different ballgame. A big part of doing this successfully is avoiding duplicate content issues and being pegged as an affiliate site with no added value. Unless you're retarded you're already mixing up and/or adding some value to the stock content provided by the merchant, but one problem remains...

When a search engine spider follows your out links, it will see them route through an affiliate network then to the merchant's site. It's easy to see that this can be used to identify your site as an affiliate site and therefore bury it in the SERPS. So what can you do?

The Solution

My epiphany happened when I was reading Rae Hoffman's post about datafeed sites. Among the tips she offers is one that made a light bulb turn on in my head:

Run your links through a blocked folder. Genius!

To make this work, first create a directory in your site's html root directory (usually "public_html"). You can name this directory anything. In this example, I'm going to name my directory "store".

The Redirect Script

In this new directory "store", create an index.php file with the following code:

<?php
// simple redirection script
// pass a get variable 'item=' with value that's urlencoded and base64 encoded
$item = $_GET['item'];
$url = urldecode($item);
$url = base64_decode($url);
header("Location: $url");
?>

This code is designed to accept a URL passed using the "item" variable and then redirect the visitor.

The Encoder Script

This next bit of code is how you encode your links.

<?php
// Simple base64 encoder
// Enter your affiliate link here
// e.g. $url = "http://www.shareasale.com/m-pr.cfm?merchantID=12345&userID=77777&productID=123 456789";

$url = "http://ctrtard.com/";

$url = base64_encode($url);
$url = urlencode($url);
echo $url;
?>

We encode the URL for the sole purposes of making it not look like an obvious affiliate link. For niche mini sites, you can just use this code to encode your links one at a time before placing them in your blog. For larger sites that have many affiliate links, you'll want to incorporate this into your site building scripts to encode all the links before generating the html.

Robots.txt

The final thing you will want to do is setup a robots.txt file and place it in your site's html root directory (public_html) that contains the following:

User-agent: *
Disallow: /store/
Usage

In the above example, the URL I chose to encode is "http://ctrtard.com/" . The encoded version of this URL is this:

aHR0cDovL2N0cnRhcmQuY29tLw%3D%3D

So to use this, you're link would be:

http://yourdomain.com/store/?item=aH...QuY29tLw%3D%3D
When the visitor clicks on the link, they will get redirected through your affiliate URL to the merchant's site. The search spiders, on the other hand, won't ever follow this link. That's because they're obeying the rule you set in your robots.txt file that tells them they are not allowed to spider anything in the "/store" directory. This prevents the search engines from indexing many links to a merchant and realizing you're simply an affiliate for XYZ merchant.

Sweet! You've just avoided leaving yet another fingerprint that says you're a an affiliate site and gained a little advantage over the competition.

Pro Tip

There is no reason you can't add on dummy variables to your links. The redirect script above only cares about the value of "item". You can easily add other dummy variables to make your links look different. For example:

http://yourdomain.com/store/?show=product-details&item=....
http://yourdomain.com/store/?zoomlevel=large&item=....

In both of these above cases, the "show" and "zoomlevel" will be ignored by the redirect script, but you still get the benefit of having it look like the on-page links are different.
#great #php #question #redirect #script #seo #tip
  • Profile picture of the author Earnie Boyd
    Sweet suggestion.

    The where would you put the code question is answered by it depends on the site.

    If you have a fairly static site you would put the encoder script in an area of the admin functions and use it to get the value of the encoded URL. Or if you have a dynamic site you would wrap the value of the link in the encoder before the page is displayed. You would only decode the item of the URL at the time someone clicked on it.

    HTH
    Signature
    {{ DiscussionBoard.errors[5871092].message }}
  • Profile picture of the author swarnet1
    try to use a shortened url domain.
    {{ DiscussionBoard.errors[5921472].message }}
  • Profile picture of the author FrankHaywood
    The search spiders, on the other hand, won't ever follow this link. That's because they're obeying the rule you set in your robots.txt file that tells them they are not allowed to spider anything in the "/store" directory. This prevents the search engines from indexing many links to a merchant and realizing you're simply an affiliate for XYZ merchant.
    Nice idea, but I don't think that will work. As I understand it from one of Matt Cutts many posts is the Google spiders will still crawl and internally index everything, but what they won't do is put the results in the public index that you and I see when we do a search. So Google will still know what you're doing and be able to take action.

    You didn't think it would be *that* easy did you?

    -Frank Haywood
    {{ DiscussionBoard.errors[5921593].message }}
    • Profile picture of the author Earnie Boyd
      Originally Posted by FrankHaywood View Post

      Nice idea, but I don't think that will work. As I understand it from one of Matt Cutts many posts is the Google spiders will still crawl and internally index everything, but what they won't do is put the results in the public index that you and I see when we do a search. So Google will still know what you're doing and be able to take action.

      You didn't think it would be *that* easy did you?

      -Frank Haywood
      Yea, Google will be Google and slaughter the poor slob trying to gain position. They want you to pay them your hard earned cash for that right.
      Signature
      {{ DiscussionBoard.errors[5922605].message }}
  • Profile picture of the author rhensiong
    Hi April,
    It is great tip. I will use your tip for my project.
    {{ DiscussionBoard.errors[6714830].message }}

Trending Topics