What's wrong with my mod rewrite for GEOIP based on location?

What's wrong with my mod rewrite for GEOIP based on location? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the What's wrong with my mod rewrite for GEOIP based on location? error on your web browser. Problem :


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.


Solution :

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.


We hope that this article has helped you resolve the redirects, mod-rewrite, geotargeting error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=