1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

Redirect by IP?

Discussion in 'Web Design' started by hawke, Apr 17, 2009.

  1. hawke

    hawke Power Member

    Nov 14, 2008
    Likes Received:
    Is there a way to redirect an AM with Known network IP address to show a different webpage than what your running one of their Offers on?

    I want to run an offer on my incentive network, but the offer doesn't allow it.

    I can blank/fake the referer, but I want the AM to see that it's comming from my domain I have registered with them. I've seen IP list's for some of the CPA Networks, and thought maybe I could redirect them by their IP address to a second copy of my site say an INDEX2.html or something.

    If it is at all possible, I need some pointers on how to start it. Thanks.
  2. drdankmendez

    drdankmendez Regular Member

    May 30, 2008
    Likes Received:
    In front of my computer
    This could be accomplished using PHP. Pretty much you would check the IP, if it matched the IP of the network then you would redirect to your 'clean' page. If its not the IP of the network display your 'dirty' page.

    On your dirty page you could add this code to the top of your page:
    $networks_ip = array('', '', '');
    $visitors_ip = $_SERVER['REMOTE_ADDR'];
    if (in_array($visitors_ip, $networks_ip)){
    	header("Location: http://www.yourCleanSite.com");
    The first line builds an array of the networks IP addresses, you simply put the ip addresses in quotes and seperated by a comma (no trailing comma).

    The second line grabs the current visitors IP address and stores it in the "$visitors_ip" variable.

    The next lines are a simple if statement that checks to see if the "$visitors_ip" exists in the array of network IP addresses. If it does then it will redirect using the header function. If the visitors ip is not contained in the array, then nothing will happen and the page will display.

    Hope this helps.
    • Thanks Thanks x 1
  3. bpaw

    bpaw Junior Member

    Aug 9, 2008
    Likes Received:
    Look into mod_rewrite. Most web hosts have it installed already.