Menu Close

Redirect by Php

Under PHP you need to use header() to send a raw HTTP header. Using headers()method, you can easily transferred to the new page without having to click a link to continue. This is also useful for search engines.

Change the code on the redirect page to be:

<?php

header( 'Location: http://www.powerhoster.com' ) ;

?>

You need to replace the URL above with the URL you wish to direct to. Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. Be sure that you do not have any text sent to the browser before this, or it will not work. Your safest bet is to simply remove all content from the page but the redirect code.

Above methods can only redirect your pages into one single webpage. But it is not use if you want to use php code to redirect to your affiliate links. You can use steve dawson ‘s php affiliate jump script to redirect to your affiliate links just like some wordpress affiliate link plugins and even much better than wordpress affiliate link plugins. Because wordpress affiliate link cloak can only link to limited affiliate links but php affiliate jump script can even links to thousands of different links.

You can click here  to download steve dawson’s php affiliate jump script. It looks like this:

<?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 href="jump.php?m=XXXXXX">XXXXXX</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();
?>

This is the first line of the PHP jump script that we will modify:

if ($m == “”) {$link = “http://www.stevedawson.com/mobiles/”;} // Default Blank

Change it so that the link points to the main page of your website. This way, if someone attempts to load the PHP jump script directly, they will be redirected to the main page of your site such as http://www.powerhoster.com.

Next, modify the second line:

if ($m == “Just Phones”) {$link = “http://www.awin1.com/awclick.php?mid=97&id=38362”;}

Replace the first section in quotation marks, “Just Phones,” with the “shortcode” that you would like to use to identify your affiliate link. For example, let’s say that you wanted to create a link to Adobe Photoshop Elements, a product that recommend and will write about in the future, at Amazon.com. Make a shortcode that makes it obvious where the link will take the reader, such as “PhotoshopElements.” Place the full link, what your affiliate tag, in the second group of quotation marks.

For example, if I were to make a link to web hosting buy plan of powerhoster using affiliate tag “hosting”, the completed line would look like this:

if ($m == “hosting”) {$link = “https://www.secureserver.net/hosting/web-hosting_4.aspx?ci=1783&prog_id=powerhoster”;}

Continue adding additional affiliate links to the PHP jump script by copying and pasting this line and modifying it, or simply adding more lines like this to the end of the script:

if ($m == “”) {$link = “”;}

Remove any incomplete lines from the PHP jump script when you are finished, and save the file. Upload it to the main directory of your website (usually the “public_html” directory). You can simply add new lines to the jump script and re-save it later as you add additional affiliate links.

For more explanation, you can check PHP Affiliate Jump Script