Different tld per language

we have 3 tlds of our domain, for different locations/languages.
I noticed kirby can do different languages per sub folder /en , /fr and so on.
but can i make a different language load per tld instead?

I don’t know for sure, but just try to set the URL-option for the language to the matching TLD? Does this work? If not, maybe just add a custom config.php (http://getkirby.com/docs/advanced/options) for each domain, and declare just every time the corresponding language as default?


Anybody actually tried this solution?

I tried the solution suggested by @jakobploens and it works.

Set up a custom config.php for each domain and declare the corresponding language as default.

1 Like

This solution could be added in the Kirby docs…

So far this solution is working but i have a problem with translated slugs.

Is working properly.

kirby.en/kontakt, kirby.dev/en/contact
Both deliver the translated content.
The slug (Url-key) is set to ‘contact’.

Is not working.

Any ideas?

I have implemented native cross-domain multilang in a Pull Request. Could you please test if that code works for you? If the code is reliable enough, it might be in the next larger Kirby release. :slight_smile:

1 Like

Works like a charme!

Thanks alot for the branch. :+1:

1 Like

did this make it into the last update - 2.3.2?

I am currently redirecting (worst case!) www.site.com -> site.com -> site.ch -> site.ch/lang/page … this seems to result in a SEO problem where Spiders are always being redirected to the englisch version of the website :slight_smile: In addition i have the feeling that this also results in way to many redirects… would this Pull Request and multi-domain set-up fix my current problem?

We own the .CH and .COM Domain, but i thought kirby was only able to use one URL, i always redirected the .COM url to .CH and have had kirby decide which Language to serve. For Spiders that always! seems to be englisch… :frowning:
This also results in two Google entries:

site.ch <- not Found
site.ch/en <- English
site.com <- English


Thanks for the Help :slight_smile:

No, it’s not yet merged. “Larger Kirby release” means 2.4. But only if it works reliably. :slight_smile:
You can already try the version from the pull request though and test if it works for you. Looking forward to your feedback.

It doesn’t seem to work with language.detect.
I have it running on http://fettmusic.de. This is my config:

c::set('languages', array(
    'code'    => 'en',
    'name'    => 'English',
    'locale'  => 'en_US',
    'default' => true,
    'url'     => 'http://fettmusic.com'
    'code'   => 'de',
    'name'   => 'Deutsch',
    'locale' => 'de_DE',
    'url'    => 'http://fettmusic.de'

c::set('language.detect', true);

My system language is English so I expect it to forward me to http://fettmusic.com when I visit http://fettmusic.de but it doesn’t.

Thank you for your feedback. I am pretty sure I have tested it when I implemented it and it worked, but I have no idea why. :wink:

A fix for language detection is now implemented on the develop branch. There will be a beta for 2.4 quite soon and this fix will be included in it as well. Which means: cross-domain multilang finally comes to Kirby. :gift:


Yeah! I updated to the latest develop branch and now the language.detect with domains works! Thanks Lukas!

That’s great, thanks for confirming.

Hi, I’m try to do the following :
Have one panel for different languages with corresponding tlds.

The Kirby Docs says about cross-domain multi-language sites :

You then need to make sure that both domains point to your Kirby site.

Do you need to set the “pointing” a specific way ?
Should it only be set with the .htaccess ?
Should I use something like:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.thedomain.com
RewriteRule (.*) http://www.thedomain.com/$1 [R=301,L]

the .htaccess of the redirected domain ?

What kind of hosting are you using? On a shared host, you usually have a control panel where you can set subdomains to specific folders/the web root. In this case, both subdomains would point to the same webfoot/folder.

When using virtual hosts on your own server, you would set the DocumentRoot for both subdomains to the same folder in the httpd.conf files for these subdomains.

My client has a .com and a .ca
Both with separate hostings but via the same registrar/host provider (docs in french… sorry): https://www.ovh.com/fr/hebergement-web/hebergement-pro.xml
With this provider it’s possible to share an FTP between domain names (docs in french too…): https://docs.ovh.com/fr/hosting/multisites-configurer-un-multisite-sur-mon-hebergement-web/#le-multisite

To present the case better we have 2 sets of contents :
For the .COM we have 3 languages: FR, ES and EN (with the European contents)
For the .CA we have FR and EN (with the Canadian contents) (fr-CA and en-CA locales)

Thoses 2 sets have ditferent contents AND share some similar contents too.
So the ultimate aim is to have a multi-regional (and multilanguage) website with the following scenarios:
If someone access via myclient.COM > detect TLD > = .COM > language.detect > FR, ES or EN of content the European content (for example: myclient.com/fr )
If someone access via myclient.CA > detect TLD > = .CA > language.detect > FR, or EN content of the Canadian content (for example: myclient.ca/ca )

I was thinking I could detect the accessed TLD (first demanded by the visitor) in PHP and THEN trigger the language.detect script.
Maybe with a $_SERVER[‘HTTP_HOST’] ? :thinking:
But maybe it’s better to do that in the .htaccess ?

I hope my explanation is clear… (And my english correct :slight_smile: )

You can use the multi-site setup to use different content folders etc. for different domains and custom config files to adjust the available languages or other settings.

The advantage would be, that you can share the kirby core files, plugins and your theme. But you won’t be able to share similar contents and editors would need to login to both sites/domain to edit the content of the corresponding site.

In short: Content would be separated, system files would be shared.

Thanks a lot @flokosiol !
After switching to a shared hosting I was able to use the setup you suggested and it works just fine !

I added this to the .htaccess to make the https url work:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

And this in the HEAD of the HTML to apply with the Google “hreflang” attribute:

<?php foreach($site->languages() as $language): ?>
    <?php if($language->default()): ?>
      <link rel='alternate' href='<?php echo $language->url() ?>' hreflang='x-default' rel='alternate'>
    <?php endif ?>
    <link rel='alternate' href='<?php echo $language->url() ?>' hreflang='<?php echo $language->code() ?>'>
<?php endforeach ?>
1 Like