0

I am working with Laravel 5.4 and simple JS and jQuery to achieve this.

I have a website from a small investment group who is active in Belgium and Holland. Two small neighbour countries. They have a few legal items on the website that differ in Belgium and Holland. When you navigate to the website, there is a JS check to determine if you are in Holland of Belgium.

$.getJSON("https://ipinfo.io",
    function (data) {
        $myLocation =  data.country;
    }
);

if ($myLocation == 'BE') {
    window.location.href = $baseurl + '/BE';
} else if ($myLocation === 'NL') {
    window.location.href = $baseurl + '/NL';
}

After I get the country from this website https://ipinfo.io I simply redirect to the baseurl + a parameter specifiek to the country. The copy is simply loaded via the Laravel standard locale and language files.

--

Problem is, I have tested this with a proxy (since I am currently in Belgium, not Holland) to see if the correct redirect is active and the correct copy is loaded. This all seems to work, but my client (who is actually in Holland) keeps getting redirected to the wrong locale.

Thanks for any input on this.

nclsvh
  • 2,628
  • 5
  • 30
  • 52
  • Whether all clients from Holland are redirected to '/BE'? Or maybe that client is on a proxy. – J Shubham Jul 10 '17 at 07:28
  • Pretty sure he is not on a proxy. He is being redirect to /BE when in Holland on iphone, windows tablet and macbook. I can only confirm this for 1 user, I am only in contact with one person in their team who is working from Holland... – nclsvh Jul 10 '17 at 08:35
  • Try changing *else if ($myLocation === 'NL') {* to *else if ($myLocation == 'NL') {* – J Shubham Jul 10 '17 at 08:41
  • Thanks, will try that and check with the client – nclsvh Jul 10 '17 at 08:56
  • Ok. And where does your page redirects if the country is neither 'NL' or "BE'? I think default locale is 'BE'. – J Shubham Jul 10 '17 at 08:59
  • If the user is in neither BE or NL there is a JS redirect to an english version of the website. I left this out of my post since that is just a fallback. But default locale is indeed set to BE, might be a factor! thanks – nclsvh Jul 10 '17 at 09:16

1 Answers1

0

Change the line:

 else if ($myLocation === 'NL') {

by this:

else if ($myLocation == 'NL') {

For difference b/w '===' and '==', refer this

J Shubham
  • 609
  • 7
  • 21