Hello how can i redirect bad traffic from iran etc. Any one who can share your .htaccess file? Thanks,
Hello how can i redirect bad traffic from iran etc. Any one who can share your .htaccess file? Thanks,
there you go mate
How to block certain countries
hope it helps
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.
Looks like we need a FAQ sticky for this question..
There are various links to different GeoIP guides in the link Aziz posted to what I posted the other day.. At least one should help you set up a working Geoip redirect.
I don't think so. Wait till they hit your site then redirect them. It shouldn't take too long to set it all up.So can't redirect people BEFORE they visit the website
Aziz (20 December, 2009)
Hey mates, I'd like to use .htaccess file with GeoIP.dat to redirect bad traffic. But could you tell me what I should do before I put "GeoIPEnable On" in .htaccess file. Or I just got 500 internal server error. THanks.
Do you have mod_geoip installed? http://www.maxmind.com/app/mod_geoip
To be able to access geoip through htaccess you'll need the module mod_geoip loaded in apache. Are you in control of your server or is it shared?
If it's shared you're most likely restricted to just running the pure php module for geoip.
If it's your own server, you can install the GeoIP C Library and the apache module, mod_geoip to beable to use it however you want.
I was going to buy the Maxmind geo database, I thought $50 is not bad, the catch was it costs $12/month for updates, so the purchase would cost $194 with a year of updates, I was thinking woah, I'll pass becuase that would drain my whole paypal account.![]()
Submit new proxies-
Haha yeah, they get you with those updates. The free version is just as good for anything I'm going to use it for. The paid version is good if you need the most accurate data possible (99.8% versus 99.5% of the free) as fast as possible (automated updates weekly versus manual updates monthly).
Well when there is 3,706,650,624 usuable Ip4 IP addresses , even .3% is a big deal.
3,706,650,624 X by .3% means there might be 11,119,951 IPv4 IP addresses that are not correctly categorized in the database... and its true, even with GeoIP blocking Iran iwth the database I get still 10,000 visits from Iran a month, So Google Analytic is more accurate, Some of the IP blocks from Iran are in that .3% range. The database could also incorrectly categorize someone from United States as from say Iran, so now you blocking United States visitors by accident. lol
Submit new proxies-
Ok, i've been using this code but i am not sure if it's working thoughdoes 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
/*
Bookmarks