Either this should be done in .htaccess, or PHP code in the header.
In this case it is important that only the store is switched, and no js, css or image files.
So the htaccess file needs to be setup as follows.
If country is USA - send visitor to domain.com/us-en/* (append full url) If country is X (we will need to provide a list of country names) send visitor to domain.com/eu-en Else, send visitor to domain.com/ca-en
We should also have the ability to exclude an IP address from this so that we can test locally. It should also be ignored by robots and spiders.
We also tried with PHP code in the header, but this did not work. Maybe there is a different way?
<?php
$country_code = $_SERVER ['HTTP_CF_IPCOUNTRY'];
if ($country_code=='US') { $link = '//domain.com/us/'; } else if ($country_code=='GB') { $link = '//domain.com/eu/'; } else if ($country_code=='DE') { $link = '//domain.com/eu/'; }
else { $link = '//domain.com/us/'; }
header('location:$link'); exit; ?>
Note that I will not be giving server access. I just need the code which I can upload myself. We also plan to edit ourselves when we need to add more countries to redirect.
I am making a website and don't have a lot of time to put into it. I have the basic framework up and running. I am in need of someone who can fix the problems i will share a documents...read more