You all know that I am in love with PHP and all it’s nice little functions and useful scripts. That is why I decided to start a new PHP Scripts category where I plan to post all those little code samples that I use and that can be useful for you too. Today I wanted to launch a new affiliate campaign on my site and I needed to put a simple PHP redirect that would make my life easier. I plan to create a dir /go on my site and in it I will place a small php files for each affiliate program that I use. That is a technique that many sites use, and basically instead of linking directly to affiliate you link to a php file on your site that does the forward to affiliate site. Why? Well there are many reasons but I will try to cover those in one of my upcoming articles, and now you need to see the code. It is very simple:

<?php
header("Location: http://somedomain.com/youraffiliatecode");
?>

You can copy paste this code into text editor like notepad and save it on your computer. You can name it whatever you like but a good practice is to name it after your sponsor. Then upload it to your site (subfolder or root, whatever you prefer) and when you hit it in your browser it will take you to the site that you put after Location: part. That’s it, hope it helps your marketing efforts!

Popularity: 22%