Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Different language per domain setup

Started by Dennis Spaan 7 years ago · 1 replies · 526 views
7 years ago

I'm using the Learn2 theme for creating two online manuals, one in Dutch the other in English. I have created two domains for this:
xxx.nl
yyy.com
I'm using the translation feature of Grav, that means each page has two versions and by placing /nl or /en at the end of the URL you will get your language. According to the Grav documentation you can create rewrite rules that point you to the right language based on the URL

I have placed these rewrite rules in my webserver based on the docs:

TXT
# handle top level e.g. https://xxx.nl/nl
RewriteRule ^nl/?$ "https://xxx.nl" [R=302,L]
RewriteRule ^en/?$ "https://yyy.com" [R=302,L]

# handle sub pages, exclude admin path
RewriteCond %{REQUEST_URI} !(admin) [NC]
RewriteRule ^nl/(.*)$ "https://xxx.nl/$1" [R=302,L]
RewriteCond %{REQUEST_URI} !(admin) [NC]
RewriteRule ^en/(.*)$ "https://yyy.com/$1" [R=302,L]

However when i go to yyy.com it still points to the default language and shows this url: yyy.com/nl instead of /en.
Did i set this up correctly?

7 years ago

You could try using the Enviroment Feature.
Pick one of your domains to be default, lets say the yyy.com is default english version, user/config/system.yaml should contain

YAML
languages:
    supported:
    - en
    - nl

And the other domain should be an enviroment:
user/xxx.nl/config/system.yaml

YAML
languages:
    supported:
    - nl
    - en

After this enviroment setup is working you should have the yyy.com opening the 'en' version, and the xxx.nl the 'nl' version.

To complete setup, you will need to add two redirects in .htaccess:
yyy.com/nl to xxx.nl
xxx.nl/en to yyy.com

Suggested topics

Topic Participants Replies Views Activity
Support · by Paul Hodges, 6 days ago
13 215 1 hour ago
Support · by gtx, 4 days ago
2 124 3 days ago
Support · by Anna, 2 weeks ago
9 298 3 days ago
Support · by TomW, 1 week ago
4 162 6 days ago
Support · by Anna, 1 week ago
4 171 7 days ago