I have flat site (html + css) sitting on a LAMP stack server which also hosts other sites.
I use mod_geoip combined with legacy GeoLite City downloaded database.
I need to get a users region to repoint them to their localised version.
The following Apache variables are available on every page load even on sites which do not require a GeoIP lookup.
- GEOIP_COUNTRY_CODE
- GEOIP_COUNTRY_NAME
- GEOIP_REGION
- GEOIP_CITY
- GEOIP_DMA_CODE
- GEOIP_AREA_CODE
- GEOIP_LATITUDE
- GEOIP_LONGITUDE
Below is my geoip.conf module file.
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoLiteCity.dat
</IfModule>
The geoip check is only required in the root .htaccess on one of my sites. As this site is flat I cannot use a dynamic language to call the geoip check.
How ca I remove this unnecessary server load?
You can set
GeoIPEnabletoOffin yourgeoip.conffile and only enable it in the relevantLocationorDirectoryblock. If you haveAllowOverride AuthConfigset, you will also be able to set it directly in your .htaccess file.