Target Country by IP Address - Geo-targeting Traffic and Redirection software

ip address location Products
· IP-Country Database
· IP-Country-Region
· IP-Country-Region-City
· IP-Country-ISP Database
· IP-Country-Region-City-ISP
· Target Country by IP Address
· Analyse Spider
· Zip Code For US

FAQ F.A.Q.
Purchase Purchase
Downloads Downloads
Contact us Contact us

IP Address Locator
IP Geolocation Articles & Tutorial (Free)

  Log File Analyzer and Log Analysis software Target Country by IP Address  

Target Country by IP Addressv2.01 - advanced redirection


1. General description
2. Installation
3. Testing and debuging PHP Target Country by IP Address
4. Useful hints

1. General description

Target Country by IP Address is a complete web-based software that provides webmasters with the ability to redirect/restrict traffic based on the visitor's country of origin.This allows webmasters to promote their services and products in different countries where they have specific distribution and service capabilities in different countries.

Install Target Country by IP Address Frequently Asked Questions
If you want to use Target Country by IP Address to safely reject all visitors from country XX and YY and to accept all the other visitors
If you want to restrict access to visitors from YY country,Or you want to block a whole lot of countries. But make exceptions for ip addresses (eg: your IP Adress).
I would like to do is redirect US, Japanese or European and rest of the world visitors to different price pages with only the $, JPY or € prices
I made the rule for NL and then there is no redirection? It just says it should do it. message: "The visitor should be redirected now to http://www.mydomain.com/order_nl.html".

2. Installation

This is not a simple cut-and-paste script. Yet installation procedure is rather short. Download the archive file containing the script and unpack it. This will contain:

  • cr/.htaccess - Apache restriction file, to deny access to cr/ folder, to avoid abuse
  • cr/anp_ips.dat - a free IP2Country database - type: Plain text full with IP numbers
  • cr/cr_free.sql - Sql Dump of the same free database
  • cr/exceptions_ips.dat - A list of IPs who will be excuded from the redirection. It can only have IP addresses (172.68.0.1) or IP address ranges; Edit this file to add exceptions ip address; Exemple:
    128.177.244.100
    194.112.94.250;194.112.94.255
  • cr/blocked_ips.dat - A list of IPs who will be excuded from the redirection. It can only have IP addresses (192.168.0.1) or IP address ranges; Edit this file to add blocked ip address; Exemple:
    213.120.148.65
    213.120.148.70;213.120.148.123
  • cr/cr.php - main script file, Edit this file for configuration
  • cr/anp_****.php - aditional functions
  • cr/Countries.php - Get Country information files
  • cr/cur_re_rules.php - default redirection rules file.
  • cr/_re_rules.php - redirection rules template file.
  • cr/Countries.* - Country information files
  • cr/flags/* - GIF country flags

    Install step by step:

  1. Edit cr/cr.php and modify it as described there.
  2. Add the next line at the beginning of EVERY PAGE YOU NEED TO REDIRECT VISITORS:
    <?PHP $anp_path="cr/"; include($anp_path."cr.php"); ?>
    or (if cr/ directory is a level up)
    <?PHP $anp_path="../cr/"; include($anp_path."cr.php");?>
  3. If you use MySql, load cr/cr_free.sql into your mysql server:
    mysql -u [username] -p
    mysql>use [your database]
    mysql>source [path to/]anp_ip2country.sql
  4. If you want a different set of redirection rules in other pages of your website,you could use the same databases and the same script.
    All you can make a copy of _re_rules.php -> new_re_rules.php,edit new_re_rules.php,just change the REDIRECTION RULES. Then include it in your files with:
    <?php $re_rules = "new_re_rules.php"; $anp_path="cr/"; include($anp_path."cr.php"); ?>

3.Testing and debuging Target Country by IP Address

  • To test and debug you need to set in cr/cr.php the constant _DEBUG_MODE to 1: define("_DEBUG_MODE","1") then poin your browser to http://yoursite.com/demo.php.
  • Now play with the configuration, modify redirection rules.
  • When you are satisfied, set _DEBUG_MODE to 2, In order to test how cookies / session vars are saved.
  • When it`s ok set _DEBUG_MODE to 0.

4. Useful hints

  • If you want to use Target Country by IP Address just to detect the country of your visitor and to get the country details in an array, edit cr/cur_re_rules.php comment out all REDIRECTION RULES and make blank the default redirect and reject links ( =""; ).
    Then edit demo.php to see how you can use the country details of your visitor.
    Add the next line:
    <?php include($anp_path."countries.php"); $anp_cinfo=get_cinfo($anp_country_code);?>
    This fields can be used in your scripts:
    $anp_cinfo["code"] $anp_cinfo["name"] $anp_cinfo["region"] $anp_cinfo["capital"] $anp_cinfo["currency"] $rv_cinfo["flag_path"] ;
    The flag image can be generated like this: <img src="<?php echo $rv_cinfo["flag_path"]; ?>" alt=""border="0">
  • Blocks certain IP address's from your site and redirects the user to a blocked page.
    You have to set : $bCheckBlocked = true; $anp_blocked_reject_link= an invalid url.
    Then Edit blocked_ips.dat,add the IP addresses or IP address ranges you want to block. Exemple:
    213.64.128.65
    213.64.108.50;213.64.148.13
  • If you want to use Target Country by IP Address to safely reject all visitors from country XX and YY and to accept all the other visitors.
    you must set :
    $anp_default_reject_link=""; $anp_default_redirect_link=""; , $anp_url_save_method="session";
    edit the Redirection Rules file(cur_re_rules.dat), for country XX uncomment the line and place an invalid url for it (XX=error.php) . Do the same for YY.
  • If you need to display language specific pages for Italy and German: $rv_default_reject_link=""; $rv_default_redirect_link=""; edit the Redirection Rules file(cur_re_rules.php), for country IT uncomment the line, as redirection rule set IT=yourpage_en.htm; Do the same for DE;
  • Finally, if you want to be 97% sure that the IP -> Country conversion is realistic, you have to use the best database on the market, database provided by us at ip2country

Copyright ©2001-2017 Jgsoft Associates. All rights reserved.