Forum Moderators: phranque
I have installed mod_geoip and have confirmed its installation with small php code
echo $_SERVER['GEOIP_COUNTRY_CODE'];
and it does show country code e.g (PH)
but when I try the following in my htaccess it makes no affect on the site
RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^PH$
RewriteRule ^(.*) http://www.example.com/second.html [R=301,L]
can anybody guide me please how to make this work with htaccess? I want to redirect all Philippines users to second.html page
many thanks
I have placed this in my htaccess now
GeoIPEnable On
GeoIPDBFile GeoIP.dat
RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^PH$
RewriteRule ^(.*) http://www.example.com/second.html [R=301,L]
but still no affect
the file GeoIP.dat exists in root folder where my htaccess exists. I guess geoip is working because as I told before my php code picks the country code from the $_SERVER array correctly
can anybody help please?
[edited by: jdMorgan at 1:12 pm (utc) on June 5, 2007]
[edit reason] Link format repair [/edit]
Apache Environment
VariableValue
GEOIP_COUNTRY_CODE PH
GEOIP_COUNTRY_NAME Philippines
but when I SSH client's server and open
vi /etc/httpd/conf/http.conf
I do not see anything like
<IfModule mod_geoip.c>
or anything else where I can see if the mod_geoip is enabled.
so should I call upon my customer's Server Admin to take any measures or the problem resides in my htaccess?
This is true of any module, whether it's PHP or geoIP, and this behaviour *is* documented at Apache.
Jim
however in the output of phpinfo() under Apache Environment I can see the country code and name etc so I am not sure if mod_geoip is working properly. Does anyone know how can I check that mod_geoip is working in the desired manner?
or any changes I should ask server admin to make in the http.conf to make the mod_geoip working properly?
thanks
now I found yet another problem... I reinstalled mod_geoip from scratch with edited httpd.conf myself to make sure everything is right on the server
the htaccess, however, is making no affect to the site.. even if write any wrong code even in the htaccess under the root directory of the site the site doesn't give 500 error which it should.
does anyone has experience to deal with this situation to make the htaccess to affect the website?
thanks
Can any apache pro guide me that why htaccess file was not affecting the website despite the htaccess was in the domain root directory where the index.html page was?
and how can I make an htaccess to work with the directory if tracked in the same kinda situation in the future.
I desperately want to learn this for my knowledge.
many thanks
For later readers, it is a good idea to start simple, test, and then move on to complex implementations a step at a time. For example, here's a good 'first rule' to put on a server when trying mod_rewrite for the first time:
RewriteEngine on
#
RewriteRule ^/?go-google\.html$ http://www.google.com [R=301,L]
Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^/?go-google\.html$ http://www.google.com [R=301,L]
With that simple rule or something similar, you can get past the obvious "mod_rewrite doesn't work at all" type problems" in a tightly-scoped test environment with few external dependencies.
Jim