I am using two languages on my Kirby site: German (default) and English. Works just fine! However, I would like to assign each language to a different domain: .de to German and .com to English. This is when things go wrong:
Both the .de and the .com domain point to the exact same page. German is the default language in both cases. When you switch to English (in the frontend), an “/en” gets added to the URL. Works!
After (when trying to assign the languages to different domains)
Still, both the .de and the .com domain get you to the exact same page. Buuut: Both times in German. When you’re accessing the .de domain and try switching to English, you get forwarded to the .com domain, but everything remains in German. No way out, apparently.
This is how my language files look like:
'code' => 'en',
'default' => false,
'direction' => 'ltr',
'locale' => 'en_US',
'name' => 'EN',
'url' => 'https://example.com'
'code' => 'de',
'default' => true,
'direction' => 'ltr',
'locale' => 'de_DE',
'name' => 'DE',
'url' => 'https://example.de'
Any ideas? Because I have none.
Any clues are much appreciated! Thank you!
PS — One strange detail I’ve noticed on the page as it is now (the “before” stage): When I type in the .de domain (German being the default language), a “/de” gets added to the URL even though it’s not specified in the
de.php (only the
'url' => '/en'.)
Which Kirby version are you using?
I am using Version 3.1.4 at the moment.
There was an issue that was fixed in 3.3.0, so please update to the latest version 3.3.1 to make this feature work.
Just updated to Version 3.3.1. It doesn’t fix the problem, this is what happens now:
In the “before” setting (German is default, both domains point to the same page):
- Still, a
/de gets added after the domain even though the
de.php file does not contain
'url' => '/de'
- The image order is mixed up, but only in a few cases. Super strange: The image order as displayed in the panel is still correct! + When swichtich to English: Correct order again!
In the new setting (.de → German, .com → English):
- Accessing the .de domain leads to an error report because of “too many redirects”.
- Accessing the .com domain leads to the .de domain and eventually to the same error report.
Have you made sure to clear the browser cache etc.? No redirects anywhere? Routes?
I’m pretty certain that this setup works, have tested it locally and other people are also using it successfully.
Yes, I’ve emptied the caches (using the ⌘⌥E command in Safari) – is there something else that needs to be reset?
It’s really strange … I feel like the problem might be related to the
de that suddenly shows up in the URL. Is has to come from somewhere, right? If it’s not in the
de.php file, is there something else I should take a look at?
Are you using any custom routes? Any manual links somewhere?
I’m sorry, I don’t know what custom routes are …
There shouldn’t be any manual links. The only precarious thing I found in the
config.php is this one:
'home' => 'arbeiten' Could that cause the problem?
The language switch looks like this:
<?php foreach($kirby->languages() as $language): ?>
<li<?php e($kirby->language() == $language, ' class="active"') ?>>
<a href="<?php echo $language->url() ?>" hreflang="<?php echo $language->code() ?>">
<?php echo html($language->name()) ?>
<?php endforeach ?>
Could you post your config file please? If you have more than one, then all.
Sure! I have only one, this is what it looks like (mostly comments):
Please add your license key, which you've received
via email after purchasing Kirby on http://getkirby.com/buy
It is not permitted to run a public website without a
valid license key. Please read the End User License Agreement
for more information: http://getkirby.com/license
// c::set('license', 'K2-PERSONAL-cfc19a42c089c1f1d705b302dcd75126');
By default you don't have to configure anything to
make Kirby work. For more fine-grained configuration
of the system, please check out http://getkirby.com/docs/advanced/options
/* Languages */
// c::set('languages', array(
// 'code' => 'de',
// 'name' => 'DE',
// 'default' => true,
// 'locale' => 'de_DE',
// 'url' => '/',
// 'code' => 'en',
// 'name' => 'EN',
// 'locale' => 'en_US',
// 'url' => '/en',
'debug' => true,
'home' => 'arbeiten',
'languages' => true
Ok, nothing special there.
Hm, I don’t know. I have a working example running locally (also works if I set the home page to another page), and it works well on this site here: https://www.fabianhemmert.com/
So wondering what might be happening on your site.
And your domains all point to the same kirby project folder?
It’s really strange. I think I might need to figure out where the
/de comes from in order to find the mistake … what do you think?
Edit: Nevermind! I added
'url' => '/' to the
de.php and now the
/de has disappeared from the URL. The overall issue remains though.
Have you also deleted the /media folder after updating?
That doesn’t make sense, if you want to use different domains, the
url property has to contain the domain. Maybe it’s a DNS issue with the second domain?
I actually didn’t. Deleted the folder now, but it doesn’t really fix the problem.
Anyway, I’m off for tonight. I can look into it some more tomorrow.
You’re right, this is my “before” setting (no differentiation between the two domains). The “too many redirects” problem occurs when I add
'url' => 'http://example.com' to
'url' => 'http://example.de' to
Alright! I am going to look into the DNS settings. Anyway: Thank you very much for your help + patience so far!
One more thing: Could you give me the domain names? If you don’t want to post them here, you can send them via PM.