I'm a bit of a newb in modrewrite but used it successfully on my server before.

I successful installed the module on my apache server and tested out with PHP test page(it correctly returned my area code) so I decided to test it out on a site and have it redirect to another page on it.

GeoIPEnable On
GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat Standard
GeoIPDBFile /usr/local/share/GeoIP/GeoLiteCity.dat Standard

    RewriteEngine On
RewriteCond %{ENV:GEOIP_AREA_CODE} ^847  
RewriteRule ^$ http://www.teetimelawncare\.com/lawncare\.html$1 [NC,QSA]

I simply get 500 Internal Server Errors every single time. Any idea why?

EDIT: I was having errors with my AddType x-mapp php5 line in my .htaccess file. Removing that allows it to work.

  • Have you checked apache's error_log? That should be your first step to get to the problem.
    – vstm
    Sep 19, 2013 at 7:52

1 Answer 1


To isolate the problem, first try it without the redirect. If it still doesn't work, then make sure that the httpd user (e.g. nobody) has read access to the GeoIP database files, as covered in the Troubleshooting section here.

Also make sure that each line in your .htaccess file or main server config ends in a newline, and remove the spacing before RewriteEngine On.

Lastly, you might want to use IndexCache, which would reduce the number of lookups and read/write access for a large database file like GeoIP City - see the example here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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