Language Detects works but won't redirect to correct URL

I’m working on a multi-language website. Dutch, default (NL) & English (EN) If I change my browser language to “English” for example it will detect the language. It works if I use:
<?= $kirby->detectedLanguage() ?>.

But it won’t redirect the user to the correct url. I can’t find documentation about how to redirect after the detection of the language.

Thanks.

1 Like

Did you delete cookies and clear the browser cache after changing the browser language?

@texnixe Yes, I also download a new browser (firefox) for it to test. Do I need to change the .httacces for this?

No, should work with the config setting.

@texnixe My config code is:

<?php

  return [
'languages' => true,
'languages.detect' => true,
'panel' => [
  'css' => 'assets/css/custom-panel.css'
]
  ];

Live link to the website:
http://dennissnellenberg.nl/dennis/

Hm, that doesn’t seem to work, I can’t find any open issues though. I wonder if it’s due to Kirby running in a subfolder. I’d have to make some tests later today.

Which Kirby 3 release are you using?

@texnixe I’m running: Kirby 3.2.0. Does it work on localhost? Because I am building via localhost. Also I released a website some days ago with the same function: https://minerva-advocaten.nl/. It is also not redirecting on that website.

Ok, I tested again locally, with Spanish (default) and German (secondary). Looks like it works as expected with default language settings (i.e. when using language codes in the Url for both languages), but not if the default language url is set to /. I consider this a bug.

@texnixe Ah I see. I changed the slug from / to “nl”. And it works perfectly. Please keep me updated if you find a solution for this problem. Thanks a lot for your help.