Results 1 to 7 of 7

Thread: Automatically redirected depending on the IP location. How to do it?.

  1. #1
    Join Date
    Feb 2008
    Location
    malaysia
    Posts
    25
    Rep Power
    0

    Automatically redirected depending on the IP location. How to do it?.

    when we are in malaysia, surf google.com, we are automatically redirected to google.com.my

    how to do this?..

  2. #2
    Join Date
    Sep 2005
    Location
    in my body lar...
    Posts
    1,325
    Rep Power
    0
    goto FREE Updated IP to Country Database

    download their ip database and source code... its all ready for u to use also.....

  3. #3
    Join Date
    Jul 2006
    Location
    LittlePenang.com
    Posts
    1,778
    Rep Power
    200
    different country google give different search result, I am using proxy to access other country google
    I blog IT Engineer LIFE at iCalvyn.com

    DreamNetwork If you don't mind Pirated

  4. #4
    Join Date
    Mar 2008
    Location
    KL
    Posts
    3
    Rep Power
    0

    easiest way

    when google.com.my pops up just type in the search

    example if you want new zealand

    just type 'google new zealand'

    then click the first result it should be for new zealand google.

  5. #5
    Join Date
    Jul 2007
    Location
    Malaysia
    Posts
    80
    Rep Power
    0
    wow...u guys ever used that script before? for developing big international websites?

  6. #6
    Join Date
    Jun 2007
    Location
    Kuala Lumpur
    Posts
    165
    Rep Power
    156
    haha, and he is so rich to purchase every country's domain for his website from .com.my buy til .com.isr (isreal) ? hahahaha..

    but that's a way, search from internet, find out the IP range for each country.

    1) create a database eg: "IPLocation" using mysql and connect the database.

    2) then create IPcountry table eg.

    create TABLE IPcountry
    (
    ipstart DOUBLE NOT NULL,
    ipend DOUBLE NOT NULL,
    country_S VARCHAR (2) NOT NULL,
    country_L VARCHAR (100) NOT NULL,
    PRIMARY KEY(ipstart, ipend)
    );

    3) then import eg "ipcountry.csv" database into the table
    eg.
    INSERT INTO IPcountry Values (XXXXX, XXXXXX, 'MAS', 'Malaysia');
    INSERT INTO IPcountry Values (XXXXX, XXXXXX, 'SG', 'Singapore');

    xxxxx represents the ip range.

    then, create ur website eg. index.php

    <?php

    // Retrieve visitor IP address
    $ipadd = getenv(REMOTE_ADDR);

    // Convert IP address to IP number for querying database
    $ipno = ipconv($ipadd);

    // Connect to the database server
    $link = mysql_connect($mysql_server)
    or die("Could not connect to MySQL database");

    // Connect to the IPLocation database
    mysql_select_db("IPLocation") or die("Could not select database");

    // SQL query string to match the recordset that
    // the IP number fall between the valid range

    $query = "SELECT * FROM IPcountry WHERE $ipno <= ipend AND $ipno>=ipstart";

    // Execute SQL query
    $result = mysql_query($query) or die("IPLocation Query Failed");

    // Retrieve the recordset (only one)
    $row = mysql_fetch_object($result);

    // Keep the country information into two different variables
    $country_S = $row->country_S;
    $country_L = $row->country_L;

    // Free recordset and close database connection
    mysql_free_result($result);
    mysql_close($link);

    // If the visitors are from SG, redirect them to SG site
    if ($countrySHORT == "MAS") {
    Header("Location: http://www.hash.com.my");
    } else {
    // Otherwise, redirect them to SG site
    Header("Location: http://www.hash.com.sg");
    }
    exit;
    // Function to convert IP address (xxx.xxx.xxx.xxx) to IP number (0 to 256^4-1)
    function ipconv ($IPaddress)
    {
    if ($IPaddress == "") {
    return 0;
    } else {
    $ips = split ("\.", "$IPaddress");
    return ($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256);
    }
    }
    ?>

    Guess this would probably works...u may try it.
    Hash here..

  7. #7
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    280
    Quote Originally Posted by calvynlee View Post
    different country google give different search result, I am using proxy to access other country google
    you dont have to.

    for using .com not .com.my use this address:
    Code:
    http://www.google.com/ncr
    NCR = no country redirection

    if you wanted to browse other country google ,
    just use their address.. as : google.cn google.jp

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Promote website by submitting to Social Bookmarking sites automatically
    By thetwo in forum Other Internet Marketing Methods
    Replies: 14
    Last Post: 02-12-2009, 11:01 PM
  2. Replies: 3
    Last Post: 03-07-2007, 02:05 PM
  3. 1U Co-location RM 200 only
    By mizan in forum Other Webmaster-related Services and Promotion
    Replies: 0
    Last Post: 22-06-2004, 10:19 PM
  4. Location
    By hftey in forum Mamak Stall
    Replies: 0
    Last Post: 01-03-2004, 12:07 PM
  5. how to make function that automatically parse url
    By full time kille in forum Website Programming
    Replies: 6
    Last Post: 08-11-2002, 05:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112