Page 2 of 8 FirstFirst 1234 ... LastLast
Results 11 to 20 of 78

Thread: How can i redirect bad traffic?

  1. #11
    vectro's Avatar
    vectro is offline I Like Stuff
    Join Date
    Dec 2008
    Location
    U.S.A.
    Posts
    632
    Thanks
    192
    Thanked 104 Times in 82 Posts
    I prefer GeoIP over sites that create big .htaccess files. It's easier to update and doesn't slow down the sites' load time. If the server uses csf/lfd for security, it also has a country blocking feature. Not all servers have those tools available, so sites like blockacountry.com come in handy as a next resort.

  2. #12
    Zean is offline Cutest Net Builder
    Join Date
    Sep 2009
    Posts
    42
    Thanks
    3
    Thanked 1 Time in 1 Post
    Hi, can you tell me the PHP Code if i want only a certain demographic to access my websites with GeoIP Lite, i'm planning allowed access only from US, UK and CA.


    i've use this code to block bad traffic from IR, CN etc. and works great.

    PHP Code:
    // Redirect Bad Visitor
    require_once 'includes/geoip.inc';

    function 
    getLocation($remoteurl) {
    $remoteurl str_replace("http://"""$remoteurl);
    $remoteip gethostbyname($remoteurl);

    $gi geoip_open("GeoIP/GeoIP.dat",GEOIP_STANDARD);

    $country geoip_country_code_by_addr($gi$remoteip);
    geoip_close($gi);

    $country strtolower($country);


    return 
    $country;
    }
    $addr getenv('REMOTE_ADDR');

    $country getLocation($addr);

    $badcountry = array('ir','cn','ng');

    if(
    in_array($country$badcountry))
    header('Location: https://www.redirected-pages.com'); 

  3. #13
    vectro's Avatar
    vectro is offline I Like Stuff
    Join Date
    Dec 2008
    Location
    U.S.A.
    Posts
    632
    Thanks
    192
    Thanked 104 Times in 82 Posts
    Quote Originally Posted by Zean View Post
    Hi, can you tell me the PHP Code if i want only a certain demographic to access my websites with GeoIP Lite, i'm planning allowed access only from US, UK and CA.
    Since I use GeoIP as an Apache module I use .htaccess code to make rules for it. There is no way to block all countries in one line, but here is .htaccess code to block the whole world. Just remove whatever countries you want to allow:

    RewriteEngine on

    SetEnvIf GEOIP_COUNTRY_CODE O1 BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AD BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AQ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AX BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE AZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BB BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BD BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BJ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BV BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE BZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CD BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CV BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CX BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE DE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE DJ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE DK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE DM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE DO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE DZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE EC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE EE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE EG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE EH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ER BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ES BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ET BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE EU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE FI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE FJ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE FK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE FM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE FO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE FR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GB BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GD BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GQ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE GY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE HK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE HM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE HN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE HR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE HT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE HU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ID BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IQ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE JE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE JM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE JO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE JP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LB BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LV BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MD BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ME BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ML BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MQ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MV BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MX BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE MZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE NZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE OM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE PY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE QA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE RE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE RO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE RS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE RW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SB BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SD BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SJ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ST BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SV BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TD BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TH BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TJ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TK BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TL BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TO BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TV BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TW BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE TZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE UA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE UG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE UM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE US BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE UY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE UZ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE VA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE VC BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE VE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE VG BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE VI BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE VN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE VU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE WF BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE WS BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE YE BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE YT BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ZA BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ZM BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE ZW BlockCountry

  4. Thanked by:

    Mike-XS (2 December, 2010), Zean (30 December, 2009)

  5. #14
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    Quote Originally Posted by vectro View Post
    Since I use GeoIP as an Apache module I use .htaccess code to make rules for it. There is no way to block all countries in one line, but here is .htaccess code to block the whole world. Just remove whatever countries you want to allow:
    Wouldn't it just be easier to only allow the countries you want versus deny everything else?

    example only allowing United States and Canada -
    Code:
    GeoIPEnable On
    GeoIPDBFile /path/to/GeoIP.dat
    
    SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
    SetEnvIf GEOIP_COUNTRY_CODE CA AllowCountry
    
    Deny from all
    Allow from env=AllowCountry
    But since Zean asked for the php code to do so, here -

    PHP Code:
    <?php

    include_once('geoip.inc');

    $gi geoip_open('/path/to/GeoIP.dat',GEOIP_STANDARD);

    // get the ip of the visitor
    $addr getenv('REMOTE_ADDR');
    // translate ip to country code
    $country geoip_country_code_by_addr($gi$addr);

    geoip_close($gi);

    $allowedCountry = array('US','CA','UK');

    // redirect them if not in allowed country array
    if(!in_array($country$allowedCountry))
    header('Location: http://www.example.com');

    ?>

  6. Thanked by:

    Mike-XS (15 April, 2011), vectro (30 December, 2009), Zean (30 December, 2009)

  7. #15
    Zean is offline Cutest Net Builder
    Join Date
    Sep 2009
    Posts
    42
    Thanks
    3
    Thanked 1 Time in 1 Post
    htascess mod still cant work i dont know where is the problem, thanks vectro

    but PHP Code by dktguy work great thanks dude

    but for United Kingdom country code isn't UK but GB

  8. #16
    vectro's Avatar
    vectro is offline I Like Stuff
    Join Date
    Dec 2008
    Location
    U.S.A.
    Posts
    632
    Thanks
    192
    Thanked 104 Times in 82 Posts
    Quote Originally Posted by dtkguy View Post
    Wouldn't it just be easier to only allow the countries you want versus deny everything else?

    example only allowing United States and Canada -
    Code:
    GeoIPEnable On
    GeoIPDBFile /path/to/GeoIP.dat
    
    SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
    SetEnvIf GEOIP_COUNTRY_CODE CA AllowCountry
    
    Deny from all
    Allow from env=AllowCountry
    Didn't know you could do that. Thanks, I was wondering.

    Quote Originally Posted by Zean View Post
    htascess mod still cant work i dont know where is the problem, thanks vectro

    but PHP Code by dktguy work great thanks dude

    but for United Kingdom country code isn't UK but GB
    I forgot to add this on the last line:

    Code:
    Deny from env=BlockCountry

  9. #17
    praja is offline Unknown Net Builder
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's not much but it's actually about $50 in my pocket - ~$30 in saved bandwidth + the $23.66 in revenue.

    BTW mainland chinese traffic is probably the very worst converting traffic in the world. I suspect russian converts much better.
    Last edited by Will.Spencer; 23 January, 2010 at 15:54 PM. Reason: Fake signature removed; Please use the signature feature of vBulletin.

  10. #18
    miamia is offline Unknown Net Builder
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Greyhound View Post
    ya, i tried to use block a country, block by ip address, deny access by country but can only block ips no redirect the traffic. How about geoip? Seems that i have to write a small php script for it. So can't redirect people BEFORE they visit the website.
    I prefer this one: http://www.ip2location.com/blockvisitorsbycountry.aspx .

  11. #19
    vectro's Avatar
    vectro is offline I Like Stuff
    Join Date
    Dec 2008
    Location
    U.S.A.
    Posts
    632
    Thanks
    192
    Thanked 104 Times in 82 Posts
    Quote Originally Posted by miamia View Post
    I prefer this one: Block Visitors by Country .
    The issue I have with ip2location and blockacountry is they generate huge lists of IP addresses that need to be copied and pasted to .htacces, which can slow things down. GeoIP can block an entire country in just 3 lines. The only problem is the server has to have GeoIP installed, which most do not.

  12. #20
    zeolshah's Avatar
    zeolshah is offline ZilZil Proxy
    Join Date
    Jan 2010
    Posts
    76
    Thanks
    1
    Thanked 1 Time in 1 Post
    Quote Originally Posted by WebEvader View Post
    Ok, i've been using this code but i am not sure if it's working though does it look correct ?

    PHP Code:
    <?php
    // PUT THIS CODE AT THE TOP OF YOUR INDEX.PHP BEFORE ANYTHING ELSE

    include('geoip/geoip.inc'); //this file must exist in your directory

    // Uncomment if querying against GeoIP/Lite City.
    // include('geoip/geoip.inc');

    $gi geoip_open('geoip/geoip.dat',GEOIP_STANDARD);

    // get the ip of the visitor
    $addr getenv('REMOTE_ADDR');
    // translate his ip to a country code
    $country geoip_country_name_by_addr($gi$addr);
    // close the geo database
    geoip_close($gi);

    $badcountry = array('Iran','Saudi Arabia','China','India','Indonesia','Kuwait','Philippines','Vietnam','Russia','Ukraine','Nigeria');

    // redirect them if they suck
    if(in_array($country$badcountry))
    header('Location: http://google.com'); //enter a url or page on your site

    $averagecountry = array ('Poland','Turkey','Finland','Denmark','Israel','Latvia');

    // redirect them if they suck
    if(in_array($country$averagecountry))
    header('Location: http://webevader.org'); //enter a url or page on your site


    /*

    Man, really thanks for that. Let me ask you; I have unlimited bandwidth, so do I really wanna use this? any harm from these countries than bandwidth misuse? Just my doubt

    Thanks in advance

Page 2 of 8 FirstFirst 1234 ... LastLast

Similar Threads

  1. Non www to www redirect
    By tetrapak in forum Managing
    Replies: 8
    Last Post: 31 May, 2010, 19:19 PM
  2. [WTS] Traffic | Traffic | Traffic | Dont forget to check inside
    By squintoo in forum Services
    Replies: 2
    Last Post: 16 October, 2009, 16:12 PM
  3. 301 redirect all to all
    By Hellas in forum Managing
    Replies: 0
    Last Post: 27 August, 2009, 13:25 PM
  4. How to redirect traffic with CSF?
    By ProxySites.ca in forum Web Hosting
    Replies: 1
    Last Post: 6 August, 2009, 00:47 AM
  5. Non-www. to www. 301 redirect
    By Dr. Stavros in forum Managing
    Replies: 8
    Last Post: 29 July, 2009, 19:51 PM

Tags for this Thread

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
  •