Redirect according to visitors' IP?

Discussion in 'HTML & Website Design' started by hvalle98, Sep 23, 2008.

  1. #1
    Hello, is there a script that redirects the visitor to another site -in my case, a subdomain- if its ip is from a certain country?
     
    hvalle98, Sep 23, 2008 IP
  2. MikeB67

    MikeB67 Member

    Messages:
    575
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    35
    #2
    I believe you can do this using .htacess
     
    MikeB67, Sep 23, 2008 IP
  3. AnonymousUser

    AnonymousUser Peon

    Messages:
    593
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You could do it in php

    e.g.

    <?php
    $Ip = $_SERVER['REMOTE_ADDR'];
    if($Ip == "xxx.xx.xx.xx")
    {
    header( 'Location: http://SiteToRedirectTo.com' ) ;
    }
    ?>
     
    AnonymousUser, Sep 23, 2008 IP
  4. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #4
    Kerosene, Sep 23, 2008 IP
  5. dpsubi1

    dpsubi1 Notable Member

    Messages:
    9,318
    Likes Received:
    420
    Best Answers:
    0
    Trophy Points:
    280
    #5
    dpsubi1, Sep 23, 2008 IP
  6. SEOpaw

    SEOpaw Peon

    Messages:
    437
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    its better to put it unto an array of IP since you need 100's of IPs for a certain country
     
    SEOpaw, Sep 23, 2008 IP
  7. AnonymousUser

    AnonymousUser Peon

    Messages:
    593
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes true, I was just showing him a example that he could copy/paste and test on himself.
     
    AnonymousUser, Sep 24, 2008 IP
  8. hvalle98

    hvalle98 Well-Known Member

    Messages:
    460
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    135
    #8
    Ok thank you!
     
    hvalle98, Sep 25, 2008 IP