Depending on the ip of the user, show him the right file, but at the same address.



  • To date, a redirector has been implemented, depending on the user ' s country, redirecting to a particular location. url

    The problem is, depending on the country, the user needs to show different pages, but the same. url

    For example,

    • The Russian user turns to test.ru/index.php See the forum
    • U.S. user test.ru/index.php sees the admin's blog.

    There's a base, there's a code on the index:

    <?php
    require_once('geo.php');
    $geoplugin = new geoPlugin();
    $geoplugin->locate();
    if ($geoplugin->countryCode == "RU") {
        $redirect_url = "http://test.ru/1.php";
    } else {
        $redirect_url = "http://test.ru/2.php";
    }
    header('HTTP/1.1 200 OK');
    header('Location:' . $redirect_url);
    

    geo.php is defined by ip and the country is online. It's not clear how to insert the right page on the index instead of the recalculation.



  • It can be done through the php. You need an IP base, like, SxGeo♪ After you're connected, you're in the middle of something like:

    <?php
      $ip = $_SERVER["REMOTE_ADDR"];
      if($SxGeo->get($ip) == 'US') {
         //тут отображение блога. Можете как-нибудь с помощью include сделать.
      } elseif($SxGeo->get($ip) == 'RU') {
         //тут форум
      }
    ?>
    

    It's the simplest example. You can use another base or even do yours. Also, if you're paranoid and afraid that someone through proxy/VPN will come to your forum, then you'll have to find ways to protect yourself.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2