We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51265
    • 32 Posts
    Did anyone else have this issue? I'm creating a multilingual website for a friend using this link: https://anyscreensize.com/blog/modx-multilingual/

    The site is in a sub folder. I've followed all the steps. All the pages in the original web context is working perfectly but when I click on the Babel link to the new context I've created, an error keeps showing.

    ERROR: This page isn’t working
    www.website-name.ie redirected you too many times.

    Is there something that I'm missing?

    This is my .htaccess code;
    # MODX supports Friendly URLs via this .htaccess file. You must serve web
    # pages via Apache with mod_rewrite to use this functionality, and you must
    # change the file name from ht.access to .htaccess.
    #
    # Make sure RewriteBase points to the directory where you installed MODX.
    # E.g., "/modx" if your installation is in a "modx" subdirectory.
    #
    # You may choose to make your URLs non-case-sensitive by adding a NC directive
    # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
    
    RewriteEngine On
    RewriteBase /subfolder/
    
    
    
    # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} ^www.website-name.ie/subfolder/ [NC]
    #RewriteRule ^(.*)$ https://www.website-name.ie/subfolder/$1 [R=301,L]
    #
    # or for the opposite domain.com -> www.domain.com use the following
    # DO NOT USE BOTH
    #
    #RewriteCond %{HTTP_HOST} !^$
    #RewriteCond %{HTTP_HOST} !^www\. [NC]
    #RewriteCond %{HTTP_HOST} (.+)$
    #RewriteRule ^(.*)$ https://www.%1/$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/$1 [R=301,L]
    
    
    
    # Redirect the manager to a specific domain - don't rename the ht.access file
    # in the manager folder to use this this rule
    #RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com$ [NC]
    #RewriteCond %{REQUEST_URI} ^/manager [NC]
    #RewriteRule ^(.*)$ https://example-domain-please-change.com/$1 [R=301,L]
    
    
    
    # The Friendly URLs part
    # redirect all requests to /en/favicon.ico
    # to /favicon.ico
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(ga|en)/favicon.ico$ favicon.ico [L,QSA]
    						  
    # redirect all requests to /en/assets* to /assets*
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(ga|en)/assets(.*)$ assets$2 [L,QSA]
    						 
    # redirect all other requests to /en/*
    # to index.php and set the cultureKey parameter
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(ga|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
    
    
    
    # Make sure .htc files are served with the proper MIME type, which is critical
    # for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
    
    #AddType text/x-component .htc
    
    
    
    # If your server is not already configured as such, the following directive
    # should be uncommented in order to set PHP's register_globals option to OFF.
    # This closes a major security hole that is abused by most XSS (cross-site
    # scripting) attacks. For more information: http://php.net/register_globals
    #
    # To verify that this option has been set to OFF, open the Manager and choose
    # Reports -> System Info and then click the phpinfo() link. Do a Find on Page
    # for "register_globals". The Local Value should be OFF. If the Master Value
    # is OFF then you do not need this directive here.
    #
    # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
    #
    # Your server does not allow PHP directives to be set via .htaccess. In that
    # case you must make this change in your php.ini file instead. If you are
    # using a commercial web host, contact the administrators for assistance in
    # doing this. Not all servers allow local php.ini files, and they should
    # include all PHP configurations (not just this one), or you will effectively
    # reset everything to PHP defaults. Consult www.php.net for more detailed
    # information about setting PHP directives.
    
    #php_flag register_globals Off
    
    
    
    # For servers that support output compression, you should pick up a bit of
    # speed by un-commenting the following lines.
    
    #php_flag zlib.output_compression On
    #php_value zlib.output_compression_level 5
    
    
    
    # The following directives stop screen flicker in IE on CSS rollovers. If
    # needed, un-comment the following rules. When they're in place, you may have
    # to do a force-refresh in order to see changes in your designs.
    
    #ExpiresActive On
    #ExpiresByType image/gif A2592000
    #ExpiresByType image/jpeg A2592000
    #ExpiresByType image/png A2592000
    #BrowserMatch "MSIE" brokenvary=1
    #BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
    #BrowserMatch "Opera" !brokenvary
    #SetEnvIf brokenvary 1 force-no-vary
    



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


      • 44195
      • 293 Posts
      As another option you could try using LangRouter with Babel. You don't need to mess with the rewrite rules or write your own gateway:
      http://jako.github.io/LangRouter/usage/
        I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
        Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
        • 51265
        • 32 Posts
        Quote from: muzzstick at Oct 09, 2018, 04:03 AM
        As another option you could try using LangRouter with Babel. You don't need to mess with the rewrite rules or write your own gateway:
        http://jako.github.io/LangRouter/usage/

        Do you by any chance have a video for this or a tutorial?

        I'm still trying the Babel but still no joy. The web context works but the new context still doesn't. The web is English but the new one is Irish. Do I need to create an ie (Irish) flexicon?
          • 46886
          • 1,154 Posts
          Ok i had an older site with two languages too. Maybe we can work this out.

          One issue is collation, the databases must be in a language. For me, I had English and Chinese, and needed to use UTF-8. If the db (made on creation) is not the right collation it will make trouble. I tried to search for Irish but couldn't really get clear info. The default is usually English-Swedish I believe. Just FYI

          Anyway, I am reading over the tutorial, is your htaccess just like their sample one? I think that is the place to start. Its a little tough because the code is hard to understand.

          This part you don't seem to have at all, its there but commented out, maybe its not needed I don't know

          	# Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
          	RewriteCond %{HTTP_HOST} .
          	RewriteCond %{HTTP_HOST} !^your-website-url\.com [NC]
          	RewriteRule (.*) http://your-website-url.com/$1 [R=301,L]



          I looked over your code, in some ways it looks fine, but in this example we are using all those languages are in addition to web context. In that example web is one language context, then DE is another one SP another one.

          You've got EN and GA contexts, you only need one with web as the other, you said English is web context? Then GA would be the only context listed in these codes, I believe...its almost like you are trying to give web and EN contexts, and the error could be due to the wrong context

          Anyway pls provide more info and let's see, it should be workable with a little tinkering






            • 46886
            • 1,154 Posts
            Hi you PM'd me but its better to keep the work public, can you agree to let me copy paste that content over here? I feel like you should agree first
              • 51265
              • 32 Posts
              Here is where I'm at at the moment. I've tried, tried and tried again to get Babel working but no joy. I keep getting a 'Redirected to many times' message.

              I'm trying to create and Irish and English language website. The Irish language is the main web context: http://www.gaeltaca.ie/nua/ and my English version is the new context en: http://www.gaeltaca.ie/nua/en/ - this is the part that I keep getting the error message.

              If truth be told.....I'm completely lost. Funny thing is, I did this for another website not so long ago (and it works) but I can't for the life of me remember how I sorted it. I remember I had the same issue there too.

              Here is my code for the .htaccess:
              # MODX supports Friendly URLs via this .htaccess file. You must serve web
              # pages via Apache with mod_rewrite to use this functionality, and you must
              # change the file name from ht.access to .htaccess.
              #
              # Make sure RewriteBase points to the directory where you installed MODX.
              # E.g., "/modx" if your installation is in a "modx" subdirectory.
              #
              # You may choose to make your URLs non-case-sensitive by adding a NC directive
              # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
              
              RewriteEngine On
              RewriteBase /nua/
              
              
              
              # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
              #RewriteCond %{HTTP_HOST} .
              #RewriteCond %{HTTP_HOST} ^www.gaeltaca.ie/nua/ [NC]
              #RewriteRule ^(.*)$ https://www.gaeltaca.ie/nua/$1 [R=301,L]
              #
              # or for the opposite domain.com -> www.domain.com use the following
              # DO NOT USE BOTH
              #
              #RewriteCond %{HTTP_HOST} !^$
              #RewriteCond %{HTTP_HOST} !^www\. [NC]
              #RewriteCond %{HTTP_HOST} (.+)$
              #RewriteRule ^(.*)$ https://www.%1/$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/$1 [R=301,L]
              
              
              
              # Redirect the manager to a specific domain - don't rename the ht.access file
              # in the manager folder to use this this rule
              #RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com$ [NC]
              #RewriteCond %{REQUEST_URI} ^/manager [NC]
              #RewriteRule ^(.*)$ https://example-domain-please-change.com/$1 [R=301,L]
              
              
              
              # The Friendly URLs part
              # redirect all requests to /en/favicon.ico
              # to /favicon.ico
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteRule ^(ie|en)/favicon.ico$ favicon.ico [L,QSA]
              						  
              # redirect all requests to /en/assets* to /assets*
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteRule ^(ie|en)/assets(.*)$ assets$2 [L,QSA]
              						 
              # redirect all other requests to /en/*
              # to index.php and set the cultureKey parameter
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(ie|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
              
              
              
              # Make sure .htc files are served with the proper MIME type, which is critical
              # for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
              
              #AddType text/x-component .htc
              
              
              
              # If your server is not already configured as such, the following directive
              # should be uncommented in order to set PHP's register_globals option to OFF.
              # This closes a major security hole that is abused by most XSS (cross-site
              # scripting) attacks. For more information: http://php.net/register_globals
              #
              # To verify that this option has been set to OFF, open the Manager and choose
              # Reports -> System Info and then click the phpinfo() link. Do a Find on Page
              # for "register_globals". The Local Value should be OFF. If the Master Value
              # is OFF then you do not need this directive here.
              #
              # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
              #
              # Your server does not allow PHP directives to be set via .htaccess. In that
              # case you must make this change in your php.ini file instead. If you are
              # using a commercial web host, contact the administrators for assistance in
              # doing this. Not all servers allow local php.ini files, and they should
              # include all PHP configurations (not just this one), or you will effectively
              # reset everything to PHP defaults. Consult www.php.net for more detailed
              # information about setting PHP directives.
              
              #php_flag register_globals Off
              
              
              
              # For servers that support output compression, you should pick up a bit of
              # speed by un-commenting the following lines.
              
              #php_flag zlib.output_compression On
              #php_value zlib.output_compression_level 5
              
              
              
              # The following directives stop screen flicker in IE on CSS rollovers. If
              # needed, un-comment the following rules. When they're in place, you may have
              # to do a force-refresh in order to see changes in your designs.
              
              #ExpiresActive On
              #ExpiresByType image/gif A2592000
              #ExpiresByType image/jpeg A2592000
              #ExpiresByType image/png A2592000
              #BrowserMatch "MSIE" brokenvary=1
              #BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
              #BrowserMatch "Opera" !brokenvary
              #SetEnvIf brokenvary 1 force-no-vary


              Here are my contexts:


              Here is the Web context - IE:


              Here is the English context - EN:


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


              Here's the installation of the Babel:
                • 46886
                • 1,154 Posts
                Great glad to see you, let's get this worked out. This way a few people can watch us work and give advice or correct me if I get something wrong.

                To start out, let's try to copy perfectly (or as much as possible) the .htaccess of the sample we have from the site.

                Pls change these three lines in your .htaccess file:

                #RewriteCond %{HTTP_HOST} .
                #RewriteCond %{HTTP_HOST} ^www.gaeltaca.ie/nua/ [NC]
                #RewriteRule ^(.*)$ https://www.gaeltaca.ie/nua/$1 [R=301,L]


                to this:

                RewriteCond %{HTTP_HOST} .
                RewriteCond %{HTTP_HOST} ^www.gaeltaca.ie/nua/ [NC]
                RewriteRule ^(.*)$ https://www.gaeltaca.ie/nua/$1 [R=301,L]


                Those hash marks I have removed from the beginning of the lines are a way to protect comments in code, the machine will see the hash and not read that line. You can do comments in any code using different methods, but with htaccess its really common to keep all the stuff there, just in case I suppose. Its even a bit odd and unusual that way.

                So, keep in mind every line of htaccess that begins with # is not used at all.

                Pls make this change and report back. You can clear the cache a few times and open with different browsers or your phone too. Then you can know what the new situation is.

                You have your install in folder /nua/, is it right?

                I just went over it, this should help as its in the model and basically everything else is the same. Then if we still have to, I have some ideas for how to check further. [ed. note: nuan88 last edited this post 5 years, 5 months ago.]
                  • 51265
                  • 32 Posts
                  I've tried that but no joy. My install is in the /nua/ folder.

                  Extra Information:
                  It's strange. All the pages in the Gaeilge (IE) side are working fine. They also have the Babel drop-down on them (image below). On the English context side, I can load all the pages except the Home Page. The Babel drop-down is on the Home page in the English Context but it's missing from the rest of the pages on the English context.

                  Irish Babel Drop-down Visible:


                  English Babel Drop-down Missing:


                  Here are a few links:
                  Irish Home Page: http://www.gaeltaca.ie/nua/
                  English Home Page: http://www.gaeltaca.ie/nua/en/

                  Irish About Us: http://www.gaeltaca.ie/nua/fuinn/
                  English About Us: http://www.gaeltaca.ie/nua/en/about-us/

                  Irish Contact: http://www.gaeltaca.ie/nua/teagmhail.html
                  English Contact: http://www.gaeltaca.ie/nua/en/contact-us.html
                    • 46886
                    • 1,154 Posts
                    Ok pls keep this new htaccess with this change as its just like the model and doesn't help when deactivated, ok?

                    No errors at all? It seems bable is certainly broken on the EN side if the dropdown is not there.

                    For me, the Irish home page isn't working either, it says this is the irish home page - baile and then has link to english page. but then the EN page is not even loading.

                    Now one thing I can think of is that normally the home page will be fixed as the home page in system settings. Do you have context settings for home page? I think you will need to be sure that the system setting for homepage is the Irish home page and then in the context I believe you can fix the homepage for the EN context

                    Well, if none of the above works then the first step is to remove the bable code and build it back up again. Something like htaccess is pretty basic and right now we don't know whether its the htaccess or something else.

                    I probably would start with removing the En side babal call and see if any change. Its that page the babal is on, right?

                    Then go on to check with both babal calls out, remember to save and clear cache. If its still broken then its an htaccess problem and we can address it as such, I think more likely its babal.

                    This could be the two babals conflicting somehow.

                    I did notice that we have to make sure your system values match up with that last line of htaccess,

                    RewriteRule ^(en|nl|de)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]

                    and make sure the culture key is being set. But that might not be what we care about now.
                      • 46886
                      • 1,154 Posts
                      It also occurs to me that you probably should tell your hoster about these problems. It theoretically could be a hoster side issue.

                      You can ask them if any rules were triggered or any other unusual activity