I'm setting up a website with four languages. I want to be able to translate the root page. I have set the website up so it serves translated content under different directories:

  • www.domain.ch/de
  • www.domain.ch/fr
  • www.domain.ch/it
  • www.domain.ch/en

I have setup a redirection so www.domain.ch/ redirects to the users browser-language, e.g. www.domain.ch/de

All of this is working fine.

How do I create a page (and translations of it) that are served directly on these urls? The root page I defined in the wpml options is not translatable.

Why is this the case? What is the right way to translate a landing page?


I set the home page as explained by @ErezLieberman in the accepted answer. To make the redirect work from www.domain.ch to www.domain.ch/[currentLanguage] I marked 'Use directory for default language' in the settings, and selected 'page' but did not create a root page.

Additionally I'm using the following code to make the redirect work. (I'm also doing a basic browser language / cookie detection)

global $sitepress;

// Redirect to language directory if we are on /
// e.g. domain.ch/ -> domain.ch/en
if (isset($sitepress)) {

    $activeLanguages = icl_get_languages();
    $onRootPage = !preg_match('/^\/' . implode('|', array_keys($activeLanguages)) . '/i', $_SERVER['REQUEST_URI']);

    if ($onRootPage) {
        $defaultLanguage = $sitepress->get_default_language();
        $desiredLang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : null;
        $langFromCookie = isset($_COOKIE['_icl_current_language']) ? $_COOKIE['_icl_current_language'] : null;

        // Language from previous cookie
        if (isset($langFromCookie) && array_key_exists($langFromCookie, $activeLanguages)) {
           $allGood = wp_redirect($activeLanguages[$langFromCookie]['url']);

        // Language from browser settings
        else if (isset($desiredLang) && array_key_exists($desiredLang, $activeLanguages)) {
            $allGood = wp_redirect($activeLanguages[$desiredLang]['url']);

        // Default language
        else {
           $allGood = wp_redirect($activeLanguages[$defaultLanguage]['url']);

        // If no filter has aborted the redirect, we redirected and can exit now.
        if ($allGood) {

NOTE: The whole system will no longer work if you ever create and set a root page. Even if you delete the root page later, it will still be stored in the settings. I had to manually set

'root_html_file_path' => null,
'root_page' => null,

in the wp_options table to null, to make sure the sytem works again.

closed as off-topic by Mark Kaplun, Pieter Goosen, TheDeadMedic, Mayeenul Islam, Howdy_McGee Dec 9 '15 at 22:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.


you need to set home page and translate it to all 4 languages and after it go to

settings->reading->Front page displays

choose the second option "A static page (select below" and choose this page

this will set the home page and root url to this page and wpml will know that the root pages of every languages is the translate of this page

  • You are right, thanks. But this solved only part of the problem. This works in all cases, except the default language: I want the default language (in my case English) to be served under www.domain.ch/en instead of www.domain.ch. When I create a redirect from www.domain.ch to www.domain.ch/en, it always redirects back to www.domain.ch, thus creating a reidrect loop. I am investigating a solution here... – dschenk Dec 2 '15 at 11:56
  • WPML->languages->Language URL format, choose the checkbox "Use directory for default language" and remove yore redirct – Erez Lieberman Dec 2 '15 at 12:04
  • 1
    That is what I had before, when I added a root page. If you check 'Use directory for default language' it automatically marks 'A page Create root page' as active. Now I get an empty page (404) when I go to www.domain.ch. Anyway, I found another solution. Will update my answer. Thanks for your help! – dschenk Dec 2 '15 at 12:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.