We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42663
    • 1 Posts

    I'm using MOXDx revo 2.2.6 with BABEL 2.2.5

    After struggling one week, I finally sat up a multilanguage website fallowing this tutorial : http://designfromwithin.com/blog-webdesign-development/2012/01/12/modx-multilingual-setting-up-babel-and-have-a-website-with-multible-languages/

    My web context is French, and I added English and Korean contexts, I still have to add Traditional Chinese and Simplified Chinese contexts.

    So everything works fine : mysite.com/en/, mysite.com/ko/ but to make it work I also had to change default web context from mysite.com. to mysite.com/fr/ and the problem is : if some people have links leading to my site like mysite.com/folder/page.html, the link will now be broken, and lead to a 404 error page, which is not my customized error page with links going to the home page but that from my server.

    So I'd like to keep my web context without /fr/ but I tried many methods and I get either mysite.com redirecting automatically to mysite.com/en/ or mysite.com/ko/ or errors.
    At worse, it would be ok if there was a way to redirect requests like mysite.com/folder/page.html to mysite.com/fr/folder/page.html but I assume that if I create a rewrite rule to add /fr/ in the URL it will add it to URL like mysite.com/en/ as well which will be then rewritten as mysite.com/fr/en/ ?

    Here are my current settings :
    # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^visit-miyajima-japan\.com [NC]
    RewriteRule (.*) http://visit-miyajima-japan.com/$1 [R=301,L]
    # or for the opposite domain.com -> www.domain.com use the following
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} !^www\.visit-miyajima-japan\.com [NC]
    #RewriteRule (.*) http://www.visit-miyajima-japan.com/$1 [R=301,L]
    # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent 
    # https://www.domain.com when your cert only allows https://secure.domain.com
    #RewriteCond %{SERVER_PORT} !^443
    #RewriteRule (.*) https://example-domain-please-change.com.com/$1 [R=301,L]
    # The Friendly URLs part
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    # detect language when requesting the root (/)
    RewriteCond %{HTTP:Accept-Language} !^(fr|en|ko)/ [NC]
    RewriteRule ^$ fr/ [R=301,L]
    RewriteRule ^$ en/ [R=301,L]
    RewriteRule ^$ ko/ [R=301,L]
    # redirect all requests to /en/favicon.ico and /ko/favicon.ico
    # to /favicon.ico
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(fr|en|ko)/favicon.ico$ favicon.ico [L,QSA]
    # redirect all requests to /en/assets* and /ko/assets* to /assets*
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(fr|en|ko)/assets(.*)$ assets$2 [L,QSA]
    # redirect all other requests to /en/* and /ko/*
    # to index.php and set the cultureKey parameter
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(fr|en|ko)?/?/(.+)$ index.php?cultureKey=$1&q=$2 [L,QSA]
    RewriteRule ^(fr|en|ko)?/?$ index.php?cultureKey=$1 [L,QSA]

    my gateway plugin :
    if($modx->context->get('key') != "mgr"){
                    /* grab the current langauge from the cultureKey request var */
                    switch ($_REQUEST['cultureKey']) {
                        case 'fr':
                            /* switch the context */
                        case 'en':
                            /* switch the context */
                        case 'ko':
                            /* switch the context */
                            /* Set the default context here */
                    /* unset GET var to avoid
                     * appending cultureKey=xy to URLs by other components */

    and the settings for my web context :

    base_url /fr/
    cultureKey fr
    site_start 2
    site_url http://visit-miyajima-japan/fr/

    I already tried with settings like : web context; base_url /, site_url http://visit-miyajima-japan/, and 'fr' removed from htaccess and gateway plugin like explained in some tutorials but didn't work for me..

    (Changing from mysite.com to mysite.com/fr/ made me also lose all the Facebook and G+ "likes" and Tweets, so I'd like to keep the former URL) [ed. note: jud3030 last edited this post 11 years, 4 months ago.]
      • 15360
      • 20 Posts
      Couldn't you just add 301 redirects to your .htaccess? The old links were showing a page in a particular language, make the 301 redirect accordingly.