Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for ways to know if an apache server receives a request , from another country (e.g germany) considering its a fair request (no spam , or proxies). I want it either to appear this as a separate entry(using dns request) in apache logs? or some kind of alert . Can this be possible.

share|improve this question

You can have Apache2 detect where the user is coming from and adjust the variables in the header so yes you can log it, and setup a cron job to phrase the logs but you need access to a GEO IP database. Not all domains, hosts resolve as .de and even if its .de doesn't mean they are German based.

mod_geoip2 Apache module

This little module allows you to detect visitors using a GEOIP database and then redirect, block, log, and many other variables within the htaccess or header request.

For example

GeoIPEnable On GeoIPDBFile /path/to/GeoIP.dat

# Redirect one country RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$     RewriteRule ^(.*)$
http://www.domainname.com$1 [R,L]

# Redirect multiple countries to a single page RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$ RewriteRule ^(.*)$
http://www.domainname.net/DE$1 [R,L]

The eaiest solution would to redirect them to a DE part of the site making the phrasing easier. You just duplicate the page and use noindex so that doesn't effect your rankings.

Check out mod_geoip2

GEO IP Databases Cost Money

IP addresses are ever expanding and changing from one country to another, in order to keep your database up to date you need to pay for this per X amount of requests. I recommend Maxmind for using their API as allows lot of freedom and pricing isn't to bad.

Simple Solution

Sorry there is no simple solution to do this, you could by all means resolve the host but many ISP's in Germany don't use just .de they use .net .com and so on! so your need a database to know what is what.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.