1

I have been using this code to redirect visitors from a number of countries to domain#2 (using GeoIP), which works fine:

RewriteCond %{HTTP_HOST} !^domain\.two$ [NC]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(TH|KH|BN|IN|LA|MY|MM|NP|PH|SG|ID|VN)$
RewriteRule ^(.*)$ http://domain.two/$1 [L]

Now I would like to redirect all countries not listed above to be redirected to domain.one. How could I archive this?

0

I found the solution:

RewriteCond %{HTTP_HOST} !^domain\.one$ [NC]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(TH|KH|BN|IN|LA|MY|MM|NP|PH|SG|ID|VN)$
RewriteRule ^(.*)$ http://domain.one/$1 [L]

The humble "!" is the key. It makes the condition work for all countries not in the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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