Forum Moderators: phranque

Message Too Old, No Replies

Redirect by country

'deny from .edu .ro .ru etc ' ... Change to a redirect?

         

tigertom

10:14 pm on Apr 1, 2007 (gmt 0)

10+ Year Member



Is is possible using mod rewrite to redirect vistors from different countries, instead of banning them?

I know you can buy an IP database, but I was wondering what environmental variable returns the country code, or indeed if that's how Apache finds it.

topr8

10:17 pm on Apr 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you still need an ip database

the country to which an ip's are allocated might change over time, theree is no rule that lets you know which country an ip address is allocated to, that's why you need a database

topr8

10:19 pm on Apr 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



although i am confused by your title:

>>deny from .edu .ro .ru etc

are you talking about refering pages or the location of the user

tigertom

10:23 pm on Apr 1, 2007 (gmt 0)

10+ Year Member



I mean the location of the user.

I suppose Apache parses the REMOTE_HOST variable, if it's set. I further suppose a mod_rewrite using a regular expression might extract the top level domain, but I'd guess it would be CPU intensive, if used for a large batch of countries(?)

jdMorgan

11:50 pm on Apr 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Parsing the REMOTE_HOST is not CPU-intensive at all, it's a simple regular expression.

However GETTING the remote host requires that for each incoming request, your server must issue an outgoing request to the DNS system, in order to resolve the remote hostname from the IP address provided in the client's request. This is what slows down the server: It must wait for the rDNS request to complete before serving the original client's request.

Also, if the rDNS lookup request fails, then the client request fails, and that makes *your* site look broken.

So, doing remote hostname lookups incurs a significant communication delay, and incurs an additional level of potential failure for your site.

For these reasons, a locally-stored database from GeoIP or a similar service is what is required to assure a responsive server.

Jim

[edited by: jdMorgan at 11:51 pm (utc) on April 1, 2007]

tigertom

10:52 am on Apr 2, 2007 (gmt 0)

10+ Year Member



Ok, thanks Jim. That's useful to know.