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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Different language per domain setup

Started by Dennis Spaan 7 years ago · 1 replies · 405 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 Thomas, 1 week ago
2 53 9 hours ago
Support · by Anna, 3 days ago
2 59 12 hours ago
Support · by Justin Young, 13 hours ago
1 30 13 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago