Page 7 of 8 FirstFirst ... 5678 LastLast
Results 61 to 70 of 78

Thread: How can i redirect bad traffic?

  1. #61
    Quote Originally Posted by _Chris_ View Post
    Thanks Mike, but how do I allow certain countries, but redirect all others please?
    Post #14 from earlier in this thread has the answer.

    On a separate note, I'm starting to like CloudFlare and so are some people who have used their sites to help me test it. It seems to know how to recognize bots and block them selectively instead of blocking an entire country or an entire IP range and having legit human users blocked in the process. Of course, some countries should still always be blocked when operating proxies.
    Last edited by vectro; 6 June, 2011 at 02:27 AM.

  2. #62
    Thanks, but how would you redirect all other countries via the .Htaccess please (it's not in post 14)

  3. #63
    Quote Originally Posted by vectro View Post
    Post #14 from earlier in this thread has the answer.

    On a separate note, I'm starting to like CloudFlare and so are some people who have used their sites to help me test it. It seems to know how to recognize bots and block them selectively instead of blocking an entire country or an entire IP range and having legit human users blocked in the process. Of course, some countries should still always be blocked when operating proxies.
    Hi Vectro,

    Thanks. This explains how CloudFlare uses data sources to challenge bad visitors and bots (figure some may wonder how we do it).

  4. #64
    Quote Originally Posted by _Chris_ View Post
    Thanks, but how would you redirect all other countries via the .Htaccess please (it's not in post 14)
    You're right. The code in post #14 is for blocking all countries except certain ones. I was looking around trying to figure out how to redirect all countries except certain ones, but can't seem to come up with anything.

  5. #65
    Quote Originally Posted by vectro View Post
    You're right. The code in post #14 is for blocking all countries except certain ones. I was looking around trying to figure out how to redirect all countries except certain ones, but can't seem to come up with anything.
    So, we're still stuck on this ;-(

  6. Quote Originally Posted by _Chris_ View Post
    So, we're still stuck on this ;-(
    It's like you're stuck on a roundabout, kinda like Chevy chase was in european vacation.

    Back in post #31 I already posted this bit of .htaccess code which redirects all other countries except the ones specified.

    Code:
    
    RewriteEngine on
    
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(US|CA|MX)$
    RewriteRule ^(.*)$ http://www.google.com$1 [L]
    I tested it out on vectro's server, and it works good. But...... That only works IF you have the Apache GEO IP mod installed. Did your host get that going ?

    If there's still no Apache GEO IP mod on your server then just do it with PHP and be done with it.

  7. #67
    It can also be done without a redirect so it generates a 'Forbidden' error instead.

    Code:
    RewriteEngine On
    SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
    SetEnvIf GEOIP_COUNTRY_CODE CA AllowCountry
    SetEnvIf GEOIP_COUNTRY_CODE GB AllowCountry
    Deny from all
    Allow from env=AllowCountry

  8. #68
    Finally, found the solution for lighttpd, I thought this thread was only for httpd so ignored it before. I installed the geo IP on my vps and then used the code gtkguy provided.

    <?php
    include_once('geoip.inc');
    $gi = geoip_open('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','NP','MX');
    // redirect them if not in allowed country array
    if(!in_array($country, $allowedCountry))
    header('Location: http://www.google.com');
    ?>

    got the geoip.inc from here http://geolite.maxmind.com/download/geoip/api/php/geoip.inc
    and copied the GEOIP database from /var/lib/GeoIP/GeoIP.dat to my site's homefolder.

    Please check if this is working, only allowed few countries. I implemented it on Anonymous Web Browsing Service

    Thank you

  9. #69
    The only problem I can see with it is the 'UK' country code should be 'GB' for United Kingdom. I'm in UK and it redirects me to a pagerank checker website. If I use a US proxy I see your proxy site instead.
    If I can't be a good example, I'll just have to be a terrible warning...

  10. #70
    Oh yes, I corrected it not familiar with those country short names. Thank you very much.

Page 7 of 8 FirstFirst ... 5678 LastLast

Similar Threads

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