0

I've tried implementing a solution I found that seemed simple enough, which is to just put this code at the top of the site's htaccess file:

#Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CH|DE|AT)$
RewriteRule ^(.*)$ ch.mysite.com$1 [R,L]

Unfortunately, this doesn't seem to do anything at all. Did I misunderstand or misuse something, or are there additional changes I should have made?

This complete beginner thanks you for any help you may provide, even a nudge in the right direction.

Rodario
  • 39
  • 5
  • How is `GEOIP_COUNTRY_CODE` being set? – anubhava Jan 11 '22 at 14:07
  • I am deducing from your question that it should be set by me somehow, so the answer is probably: It's not. I thought the above code was all that's needed and assumed the information came from the user's browser. – Rodario Jan 11 '22 at 14:26
  • The `GEOIP_COUNTRY_CODE` environment variable is probably set by mod_geoip. However, this is not a standard Apache module and you will need to install and configure this yourself on your server. https://github.com/maxmind/geoip-api-mod_geoip2 – MrWhite Jan 11 '22 at 16:33
  • Unfortunately I can't do that with siteground hosting, so I guess I'll have to search for a different solution altogether. I tried the redirect plugin for wordpress (because it was recommended in a similar question thread) but there's no options for conditional redirects unless I'm blind. – Rodario Jan 11 '22 at 19:27
  • @Rodario, Have you found the solution? – user9437856 Nov 18 '22 at 07:24

0 Answers0