How to GEO-Redirect CPA Traffic | Step By Step Tutorial

Some countries convert better on a particular CPA network while some on the other. That’s why we need a tool that could redirect automatically based on the location of the user. Therefore, In this Tutorial, we are going to learn how to do exactly that.

Step 1:

Navigate to the cPanel of your hosting and click “PHP Pear Packages.”


Step 2:
In the search box, type “GeoIp,” and click “GO.” You will see “Net_GeoIP (1.0.0)” is the 1st option. Install it by clicking “Install.”


Step 3:

Now, that we have installed the PHP software, it’s time to get a database of IP ranges. Go over to this link and download the latest database.


Step 4:
Now, go to the file manager of your hosting and navigate to the “PHP” folder and then to the “NET” folder. Upload your downloaded database here. Make sure to upload the “.DAT” file and not the Gzipped archive.

Step 5:
Since everything is done on the software side, it’s time to create our PHP file. Make sure to replace the texts highlighted with your own.


// Change the location of both xyzs with your details
require_once ‘/home/xyz/php/Net/GeoIP.php’;
$geoip = Net_GeoIP::getInstance(‘/home/xyz/php/Net/GeoIP.dat’);

try {
$country = $geoip->lookupCountryCode($_SERVER[‘REMOTE_ADDR’]);

switch((string)$country) {

// For Indian Traffic
case ‘IN’:
$url = “”;

// For USA Traffic
case ‘US’:
$url = “”;

// For the Rest
$url = “”;

header(‘Location: ‘.$url);
} catch (Exception $e) {
// Handle exception


This file will redirect Indian traffic to Google and US traffic to Bing. The default location of all the others will be CPAElites. You can create as many cases as you want by writing in the short codes one after the other.

Step 6:
Upload the file to your web hosting and provide the Link to whomever you want.


Hakunamatata! Rpkrocks is here to share and offer valuable services.

Recent Posts