Creating an affiliate redirect page with PHP
Posted on October 24, 2007
Filed Under PHP Scripts
So you have joined an affiliate program and wish to drive traffic to the website without revealing your affiliate link, why not create a simple affiliate redirect page using PHP.
In this example, we’ll create a stand-alone PHP page which will contain your affiliate link. When the online user visits your new page, they will be automatically re-directed to the affiliate website. A database connection for this example is not required, you simply need for PHP to enabled on your web host.
Why create an affiliate redirect page?
Many times online users simple will not click on a link if they notice that the link does not point to another location within your website. You may also want to hide your affiliate links on your website, or you may simple not want the search engine bots to crawl the affiliate link. The reasons are many.
Some affiliate links look ugly! They may be very long or may be filled with various special characters.
Case in example: An affiliate link for cheap website hosting
In this simple example, you could post you link in the following format:
https://www.securepaynet.net/gdshop/hosting/shared.asp?prog_id=sitebuilder&ci=1783&
or in this format:
Cheap web hosting (opens in new window)
but either way, by hovering your mouse over the links, you will see the affiliate URL in the status bar of your browser.
The redirect in PHP is based on the header function in PHP
Step 1: Create a new PHP file
Using a text editor, enter the following in to the file
<?php
// Simple redirection example
header(‘Location: http://www.example.com/’);
?>
As in the above example, simply change the ‘http://www.example.com/’ to your affiliate link so that it would look something like this:
<?php
// Simple redirection example
header(‘Location: https://www.securepaynet.net/gdshop/hosting/shared.asp?prog_id=sitebuilder&ci=1783&’);
?>
An even better to put together this file is:
<?php
// Simple redirection example
$AffURL = “https://www.securepaynet.net/gdshop/hosting/shared.asp?prog_id=sitebuilder&ci=1783&”;
header(”Location: $AffURL”);
exit;
?>
Step 2: Save the file to your web host provider
Give your new .php file a name such as ‘cheap-web-hosting.php’, ‘discount-hosting.php’ or something similar and save the file to your web server.
Now on your domain name, you should have a file with a URL address similar to this:
http://www.yourdomain.com/cheap-web-hosting.php
Step 3: Test it
If done correctly, when you access the new page you created, you will be automatically be redirected to the affiliate website.
Download this php file
You can view the content of this file here …
Now instead of placing your affiliate link on your website, you can simply link to your redirect page, which will look something like this: Cheap web hosting. The link looks cleaner and your affiliate link is cloaked!
Happy affiliate marketing!
Comments
2 Responses to “Creating an affiliate redirect page with PHP”
How can I do a redirect when the affiliate link is javascript?
Here’s a simple Javascript example
http://www.tizag.com/javascriptT/javascriptredirect.php