Y T Nuke  
Results 1 to 14 of 14
I need a redirection script that will redirect all USA traffic to one page and ...
  1. #1
    sapo's Avatar
    sapo is offline Regular Member
    Join Date
    Feb 2008
    Posts
    396
    Reputation
    43
    Thanks
    144
    Thanked 166 Times in 98 Posts

    Default url redirection based on Location

    I need a redirection script that will redirect all USA traffic to one page and every other to another. let me know. I need this ASAP so whoever can help Gets rep whenever I see your post lol
    Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28

  2. #2
    sirgold's Avatar
    sirgold is offline Power Member
    Join Date
    Jun 2010
    Location
    A hot one
    Posts
    781
    Reputation
    134
    Thanks
    26
    Thanked 260 Times in 191 Posts

    Default Re: url redirection based on Location

    Download the appropriate files for php here: maxmind.com

    This should do the trick

    Code:
    <?php
    
    include("geoip.inc");
    $ip=$_SERVER['REMOTE_ADDR'];
    $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
    
    $country_code = geoip_country_code_by_addr($gi, "$ip");
    
    geoip_close($gi);
    
    switch($country_code) {
      case "US": header("Location: http://US-URL"); break;
      default: header("Location: http://RestOfTheWorld-URL");
    }
    ?>

  3. The Following User Says Thank You to sirgold For This Useful Post:

    sapo (12-17-2011)

  4. #3
    sapo's Avatar
    sapo is offline Regular Member
    Join Date
    Feb 2008
    Posts
    396
    Reputation
    43
    Thanks
    144
    Thanked 166 Times in 98 Posts

    Default Re: url redirection based on Location

    Thanks But I couldent figure it out, Just gives me a blank page no redirection happens
    Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28

  5. #4
    arcticfang's Avatar
    arcticfang is offline Elfen Lied & Sekirei <3
    Join Date
    Aug 2010
    Posts
    259
    Reputation
    90
    Thanks
    186
    Thanked 193 Times in 81 Posts

    Default Re: url redirection based on Location

    Are the geoip.dat and geoip.inc files both inside the same folder as the page?

  6. The Following User Says Thank You to arcticfang For This Useful Post:

    sapo (12-17-2011)

  7. #5
    sapo's Avatar
    sapo is offline Regular Member
    Join Date
    Feb 2008
    Posts
    396
    Reputation
    43
    Thanks
    144
    Thanked 166 Times in 98 Posts

    Default Re: url redirection based on Location

    Quote Originally Posted by arcticfang View Post
    Are the geoip.dat and geoip.inc files both inside the same folder as the page?
    I might sound dumb but I couldent find no geoip.dat

    I have the geoip.inc but no .dat

    LOL I am a idiot I just had to scroll down and read some more, damn their font too small thats my excuse lol
    Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28

  8. #6
    sapo's Avatar
    sapo is offline Regular Member
    Join Date
    Feb 2008
    Posts
    396
    Reputation
    43
    Thanks
    144
    Thanked 166 Times in 98 Posts

    Default Re: url redirection based on Location

    now both the files are in the same folder but still no redirection just blank
    Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28

  9. #7
    arcticfang's Avatar
    arcticfang is offline Elfen Lied & Sekirei <3
    Join Date
    Aug 2010
    Posts
    259
    Reputation
    90
    Thanks
    186
    Thanked 193 Times in 81 Posts

    Default Re: url redirection based on Location

    Could you paste the entire code you have here?

  10. #8
    sapo's Avatar
    sapo is offline Regular Member
    Join Date
    Feb 2008
    Posts
    396
    Reputation
    43
    Thanks
    144
    Thanked 166 Times in 98 Posts

    Default Re: url redirection based on Location

    Quote Originally Posted by arcticfang View Post
    Could you paste the entire code you have here?
    its the same as that person provided

    Code:
    <?php
    
    include("geoip.inc");
    $ip=$_SERVER['REMOTE_ADDR'];
    $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
    
    $country_code = geoip_country_code_by_addr($gi, "$ip");
    
    geoip_close($gi);
    
    switch($country_code) {
      case "US": header("Location: http://yahoo.com"); break;
      default: header("Location: http://google.com");
    }
    ?>
    and i have geoio.inc and GeoIP.dat in the same directory as this index.html file
    Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28

  11. #9
    sirgold's Avatar
    sirgold is offline Power Member
    Join Date
    Jun 2010
    Location
    A hot one
    Posts
    781
    Reputation
    134
    Thanks
    26
    Thanked 260 Times in 191 Posts

    Default Re: url redirection based on Location

    The code works great, just retested on one of my servers OP.

    1. Delete the 2 files geoip.inc and GeoIP.dat you have now (maybe tainted?)

    2. Make sure you get the geoip.inc from here:

    http://geolite.maxmind.com/download/.../php/geoip.inc

    3. get geoip.dat.gz (that you'll decompress so you'll end up with GeoIP.dat) from here:

    http://geolite.maxmind.com/download/...y/GeoIP.dat.gz

    Retry and it'll work for sure.

    HTH!

    Quote Originally Posted by sapo View Post
    its the same as that person provided

    Code:
    <?php
    
    include("geoip.inc");
    $ip=$_SERVER['REMOTE_ADDR'];
    $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
    
    $country_code = geoip_country_code_by_addr($gi, "$ip");
    
    geoip_close($gi);
    
    switch($country_code) {
      case "US": header("Location: http://yahoo.com"); break;
      default: header("Location: http://google.com");
    }
    ?>
    and i have geoio.inc and GeoIP.dat in the same directory as this index.html file

  12. The Following User Says Thank You to sirgold For This Useful Post:

    sapo (12-18-2011)

  13. #10
    sapo's Avatar
    sapo is offline Regular Member
    Join Date
    Feb 2008
    Posts
    396
    Reputation
    43
    Thanks
    144
    Thanked 166 Times in 98 Posts

    Default Re: url redirection based on Location

    Quote Originally Posted by sirgold View Post
    The code works great, just retested on one of my servers OP.

    1. Delete the 2 files geoip.inc and GeoIP.dat you have now (maybe tainted?)

    2. Make sure you get the geoip.inc from here:

    http://geolite.maxmind.com/download/.../php/geoip.inc

    3. get geoip.dat.gz (that you'll decompress so you'll end up with GeoIP.dat) from here:

    http://geolite.maxmind.com/download/...y/GeoIP.dat.gz

    Retry and it'll work for sure.

    HTH!
    Did everything you said and still just blank and when i check the source the code is their but it just doesnt trigger a redirection.
    Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28

  14. #11
    Autumn's Avatar
    Autumn is offline Elite Member
    Join Date
    Nov 2010
    Location
    Spamville
    Posts
    2,030
    Reputation
    1778
    Thanks
    518
    Thanked 2,361 Times in 1,092 Posts

    Default Re: url redirection based on Location

    Are you using this on an html page? You shouldn't be able to see any source code when you load the page in your browser from your web server. Your page must have a .php file extension and you should be inserting that code before the opening <html> tag. You must test this on a web server - just opening the page in your browser from your local hard drive won't parse the php code.

    If you want to parse .html files for php includes, you can set that up in your .htaccess file (google "parse php in html htaccess").
    "An ounce of action is worth a ton of theory." - Ralph Waldo Emerson

  15. The Following User Says Thank You to Autumn For This Useful Post:

    sapo (12-18-2011)

  16. #12
    sapo's Avatar
    sapo is offline Regular Member
    Join Date
    Feb 2008
    Posts
    396
    Reputation
    43
    Thanks
    144
    Thanked 166 Times in 98 Posts

    Default Re: url redirection based on Location

    Quote Originally Posted by Autumn View Post
    Are you using this on an html page? You shouldn't be able to see any source code when you load the page in your browser from your web server. Your page must have a .php file extension and you should be inserting that code before the opening <html> tag. You must test this on a web server - just opening the page in your browser from your local hard drive won't parse the php code.

    If you want to parse .html files for php includes, you can set that up in your .htaccess file (google "parse php in html htaccess").
    LMFAO soon as i read that I faced Palmed, Its works man, Thankfs for clearing that up.. Thanks evefyoen for their help
    Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28

  17. #13
    arcticfang's Avatar
    arcticfang is offline Elfen Lied & Sekirei <3
    Join Date
    Aug 2010
    Posts
    259
    Reputation
    90
    Thanks
    186
    Thanked 193 Times in 81 Posts

    Default Re: url redirection based on Location

    Oh wow, that's hilarious. lol Glad everything worked out.

  18. The Following User Says Thank You to arcticfang For This Useful Post:

    sapo (12-18-2011)

  19. #14
    sirgold's Avatar
    sirgold is offline Power Member
    Join Date
    Jun 2010
    Location
    A hot one
    Posts
    781
    Reputation
    134
    Thanks
    26
    Thanked 260 Times in 191 Posts

    Default Re: url redirection based on Location

    Checklist:

    1. You put the above code into a file with a php extension, right (not htm/html)?
    2. You are testing this with a hosting that actually supports php (you never know...)?
    3. To do some infamous "printf debugging" change this part 'header("Location: http://yahoo.com");' with 'echo "I am a US visitor";' and see if it shows up.

    If this is not the case it eludes me how such a simple snippet wouldn't work for ya.

  20. The Following User Says Thank You to sirgold For This Useful Post:

    sapo (12-18-2011)

Dot Gov Backlinks Sale


Smarter Submit

Similar Threads

  1. unwarping / decoding URL redirection?
    By SEOfarmer in forum Black Hat SEO
    Replies: 0
    Last Post: 11-09-2011, 04:08 PM
  2. Can I buy ip addresses based on location?
    By klionheart in forum Web Hosting
    Replies: 5
    Last Post: 07-27-2011, 05:55 PM
  3. Adsense based on user's location
    By Water damage in forum Adsense
    Replies: 2
    Last Post: 05-17-2011, 05:12 AM
  4. WHOIS based on location
    By cashfap in forum Black Hat SEO
    Replies: 0
    Last Post: 04-29-2011, 12:11 PM
  5. redirection from one url to another same domain
    By aldragon in forum PHP & Perl
    Replies: 6
    Last Post: 02-01-2011, 05:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  SEnukeX SEO Software
Proudly Powered by Hostwinds.com Web Hosting Click Here For Exclusive BHW Discounts!

Cheap Web Hosting


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