About MeArchivesHow TosWhat Is?Generate CashCase StudiesMediaResourcesMy SitesAdvertiseNewsletterContact

PHP Redirects And Hiding Affiliate Links

April 12, 2008

Miscellaneous

Just a quick post to show you how I hide my affiliate links by using a PHP redirect. It’s not the only way to do it but it’s easy and helps to keep things organized…and hidden.

First step is to create a folder on the server to store your redirect files in. One way to create a folder on the server is though FTP. If you need to learn how to FTP, here is a quick FTP tutorial. I always create a folder called “go” but it can be anything. I’ve seen people use “recommends” or “jump” etc. but it doesn’t matter a whole lot what it’s called.

What we are doing here is adding our affiliate URL to a text file and saving it with an appropriate name. Then when we link to the file, which is on our server, it will redirect over to the affiliate offer, therefore keeping the actual URL hidden from prying eyes. For example, from this site I might have an affiliate link for GoDaddy. I would create a text file called godaddy.php with the appropriate code (the code is below) and put the file into my “go” folder. Now when I link to it from a post or page, I would link to http://keithjameslock.com/go/godaddy.php.

Tip: Be sure when including the link in a post that you use the full link with the http:// and domain name. If you were to use /go/godaddy.php for the link, it would work from the web site but it wouldn’t work from your RSS feed. Using the full URL ensures that it’ll work from any site your feed is displayed on (including your own).

PHP Redirect Code

Use the code below to setup your redirect. I always create a template file called redirect.php and when I need to create a new redirect I open up the file, change the affiliate URL and save it with the appropriate name and then upload it to the server.

Here’s the code:

<?php
$redirecturl = 'AFFILIATE URL GOES HERE';
header('location: '.$redirecturl);
?>

You should probably prevent the redirect folder, in this case “go”, from being crawled by search engines. If you aren’t sure what I mean, the next post will be covering it.

About Keith Lock

Keith has been in the affiliate marketing field for 10+ years working in a variety of niches along the way. His extensive technical background has allowed him to gain a significant advantage while marketing online. Keith primarily writes detailed step-by-step guides and product/service reviews in the make money online niche.

View all posts by Keith Lock

© Earn A Living Online in Your P-Jizzle's.

Subscribe

Subscribe to get alerted by e-mail when a new article is added.

Get Exclusive Money Making Tips:

Market Samurai Free

Trackbacks/Pingbacks

  1. Prevent Certain Wordpress Folders From Being Crawled By Search Engines | KeithJamesLock.com - April 12, 2008

    [...] ← PHP Redirects And Hiding Affiliate Links [...]

Leave a Reply