We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8489
    • 90 Posts
    Is it possible to have the default language without the language code (en) in the url

    like this:

    http://www.website.eu (english default language, without "en" in the url)
    http://www.website.eu/de (german part)
    http://www.website.eu/fr (french part)


    Thanks!
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Set up your contexts like that, so with right base_url setting (either /, /de/ or /fr/).

      And find a way (plugin most likely in this case) to initialize the right context.

      http://rtfm.modx.com/display/revolution20/Using+One+Gateway+Plugin+to+Manage+Multiple+Domains
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 8489
        • 90 Posts
        Thanks Mark! I will try so.
          • 8489
          • 90 Posts
          I have set it up as below, but when browsing to the website it keeps redirecting to http://www/website.eu/nl/

          Gateway:

          if($modx->context->get('key') != "mgr"){
              /* grab the current langauge from the cultureKey request var */
              switch ($_REQUEST['cultureKey']) {
                  case 'de':
                      /* switch the context */
                      $modx->switchContext('de');
                      break;
                  case 'en':
                      /* switch the context */
                      $modx->switchContext('en');
                      break;
                  default:
                      /* Set the default context here */
                      $modx->switchContext('web');
                      break;
              }
              /* unset GET var to avoid
               * appending cultureKey=xy to URLs by other components */
              unset($_GET['cultureKey']);
          }


          .htaccess:

          RewriteEngine On
          RewriteBase /
          
          RewriteCond %{HTTP_HOST} .
          RewriteCond %{HTTP_HOST} !^www\.website\.eu [NC]
          RewriteRule (.*) http://www.website.eu/$1 [R=301,L]
          
          # The Friendly URLs part
          # detect language when requesting the root (/)
          RewriteCond %{HTTP:Accept-Language} !^(de|en) [NC]
          RewriteRule ^$ nl/ [R=301,L]
          RewriteRule ^$ de/ [R=301,L]
          RewriteRule ^$ en/ [R=301,L]
          
          # redirect all requests to /en/favicon.ico and /de/favicon.ico
          # to /favicon.ico
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule ^(nl|de|en)/favicon.ico$ favicon.ico [L,QSA]
           
          # redirect all requests to /en/assets* and /de/assets* to /assets*
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule ^(nl|de|en)/assets(.*)$ assets$2 [L,QSA]
           
          # redirect all other requests to /en/* and /de/*
          # to index.php and set the cultureKey parameter
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(nl|de|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
          
          AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
          
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            I tend to copy the index.php, config.core.php and .htaccess file to every location (ie: put them in /de/ for the german translation) and change the context being initiated in there.

            I don’t have any experience with the htaccess/plugin method, but I suspect this being the problem:
            # The Friendly URLs part
            # detect language when requesting the root (/)
            RewriteCond %{HTTP:Accept-Language} !^(de|en) [NC]
            RewriteRule ^$ nl/ [R=301,L]


            You’re rewriting to nl/ there, while I think you should just leave that out and let it pass an empty cultureKey which then uses the web context in your plugin.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 8489
              • 90 Posts
              Thanks Mark, I think I will just use the nl part in the url as it gets to complicated.
              Antoher thing that is happening when using the normal set up of babel if I go to http://www.website.eu/de/ it gives a 404 page not found.
              Only when I point to http://www.website.eu/de/home-de it loads the startpage.

              Thanks again for your help!
                • 18373 ☆ A M B ☆
                • 3,141 Posts
                Set a site_start variable in your context settings, pointing to the homepage per context.
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 8489
                  • 90 Posts
                  Thanks again Mark will try that!

                  What do you think about nl in the url in seo point of view?
                    • 18373 ☆ A M B ☆
                    • 3,141 Posts
                    In all honesty I don’t think it’ll matter much unless people would be searching for the site name dot nl, where Google may be able to decipher it need the Dutch translation...
                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                      • 8489
                      • 90 Posts
                      Thanks Mark for your time and help!!!
                      I have to think about to use Babel, or just use subfolders inside the web context and go for the drag en drop.