How To Redirect URL In PHP

July 18, 2013

0 Flares 0 Flares ×

A simple way of redirecting an URL to another URL is to use what is known as a PHP jump script.

Affiliate marketers often use PHP jump scripts or other redirection methods to so that their affiliate link remains hidden. Depending on the affiliate network however, this does not always disguise the affiliate link in the URL address bar.

This source code has been taken from Steve Dawson’s website at www.stevedawson.com.

The method is quite simple – first copy and save the script below as Jump.php and upload it to your website’s root folder. The root folder is usually public_html

To add or change affiliate links, simply modify the text in $m == “Just Phones” ie change “Just Phones” to another keyword or reference word.

Then change $link = “put your affiliate link in here”

Then add the link URL to your site using

<a rel=”nofollow” href=”jump.php?m=XXXXXX”>Anchor Text</a>

Change the XXXXXX for the text you entered in the $m == ie in this example – Just Phones

<?PHP // This script is to be used with the Affiliate Jump Tutorial at www.stevedawson.com/articles.php
/************************************************************************/
/* PHP Affiliate Jump Script */
/* =========================== */
/* */
/* Written by Steve Dawson – http://www.stevedawson.com */
/* Freelance Web Developer – PHP, MySQL, HTML programming */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* but please leave this header intact, thanks */
/************************************************************************/
/*
Save this page as jump.php and when linking to this script use the following:
<a rel=”nofollow” href=”jump.php?m=XXXXXX”>anchor text</a>
Where XXXXXX is your merchant.
*/
$m = $_GET[‘m’];
if ($m == “”) {$link = “http://www.stevedawson.com/mobiles/”;} // Default Blank
if ($m == “Just Phones”) {$link = “http://www.awin1.com/awclick.php?mid=97&id=38362″;}
if ($m == “UKPhoneShop”) {$link = “http://tracker.tradedoubler.com/click?p=985&a=949731&g=5119″;}
/*
To add more jump links, just copy and paste one of
the lines above and modify the $m and $link values
*/
header(“Location: $link”); // Jump to the hiddden affiliate URL above
exit();
?>

If your blog is a wordpress blog, you can simply use a plugin such as Eclipse Link Cloaker or Pretty Link Pro

These plugins will do all the heavy lifting for you and you can configure them how you like.

For example Eclipse Link Cloaker will allow you to select from different types of redirects such as:

301 Permanent Redirect
302 (Default)
307 Temporary Redirect
Double META refresh (Hides the referrer)
Shows the target in a frame. (Cloaks the address bar)

One of my favourite features of Eclipse Link Cloaker is that you can have affiliate links or links to outside sites redirected automatically, but internal links on your site will be left alone by adding your site name to a list of exclusions.

There are also options for adding rel=nofollow to external links to prevent search engines from following them.

  Subscribe below and get the latest updates from Wag

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: