Forum Moderators: phranque
I am trying to redirect visitors by HTTP_REFERER and GeoIP
I was using several months with the GeoIP redirection without any problems but when I added additional redirection for few domains in my httpd.conf than the servers started showing me this message only "Bad Request"
I noticed few things:
1)when I use the HTTP_REFERER redirection in .htaccess file on another domain witch doesn't include the GeoIP redirection in the httpd.conf file than everything works fine.
2)when I use the HTTP_REFERER redirection in .htaccess file on domain with GeoIP redirection in the httpd.conf file then the HTTP_REFERER redirection is not working.The server just pass the the HTTP_REFERER redirection in the .htaccess file
3)when I place both types of redirection in the httpd.conf then the server returns me BAD REQUEST
here are both types of redirection I am trying to run together
httpd.conf
=====================================
GeoIPEnable On
GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat
RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^KP$ [OR]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^KR$ [OR]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^TW$ [OR]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$ [OR]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^BR$
RewriteRule ^/index\.shtml /indexx.shtml [nc]
#################
RewriteCond %{HTTP_REFERER} ^http://.*domain1.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://.*domain2.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://.*domain3.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://.*domain4.*$
RewriteRule ^(.*)\.shtml$ indexx.shtml [nc]
Welcome to WebmasterWorld!
Try simplifying this code and adding a RewriteCond to prevent looping in the second rule:
GeoIPEnable On
GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat
RewriteEngine On
#
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(KP¦KR¦TW¦CN¦BR)$
RewriteRule ^/index\.shtml$ /indexx.shtml [NC,L]
#
RewriteCond %{REQUEST_URI} !^/indexx\.shtml$
RewriteCond %{HTTP_REFERER} ^http://(www\.)?domain1\.com [OR]
RewriteCond %{HTTP_REFERER} ^http://.*domain2 [OR]
RewriteCond %{HTTP_REFERER} ^http://.*domain3 [OR]
RewriteCond %{HTTP_REFERER} ^http://.*domain4
RewriteRule \.shtml$ /indexx.shtml [NC,L]
Change all broken pipe characters "¦" above to solid pipes before use; Posting on this forum modifies the pipe characters.
Jim