Okay
  Public Ticket #1151542
Need help with Country Detect & Redirect
Closed

Comments

  • nyc02 started the conversation

    Hi,

    I would like to use your script to block (redirect) all country to google.com or a web page… and only allow USA to access to my site. Can you please show me how to do that with your script.

    Thank you so much for your help.

    nyc02


  • [deleted] replied

    Hi nyc02,

    You can use this code:

    include("../src/CountryDetector.class.php");

    if ( CountryDetector::is( 'AMERICA' ) ) {
    header( 'Location: http://www.google.com' );
    exit;
    }

    However I suggest you to save a cookie cache and prevent the same users who access the site regularly, thus it will not increase the load time and also reach API limits.