We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53724
    • 15 Posts
    Hi, I'm trying to configure LangRouter with Babel locally on wamp. But I have issues. Modx is installed in modx folder, so the root link is http://localhost/modx.

    The links for home pages in any of the languages are not working, but for error pages or the wrong specified paths are.

    For configuring babel i was following this tutorial: https://anyscreensize.com/blog/modx-multilingual/ , for langRouter I was going through the official documentation: http://jako.github.io/LangRouter/usage/

    Friendly URL and use_alias_path are enabled, gateway plugin is disabled, because I read somewhere that it is not recommended to have two plugins running at the same time.

    Example:
    localhost/modx/en/ not working
    localhost/modx/en/blabla working

    .htaccess
    RewriteEngine On
    RewriteBase /modx

    # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
    #RewriteRule ^(.*)$ https://%1/$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]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(en|de)/favicon.ico$ favicon.ico [L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(en|de)/assets(.*)$ assets$2 [L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(en|de)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]

    [ed. note: unforgiven666 last edited this post 6 years, 3 months ago.]
      • 3749
      • 24,544 Posts
      It may not be causing your problem, but you should definitely uncomment one of these two sections:

      # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
      #RewriteCond %{HTTP_HOST} .
      #RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
      #RewriteRule ^(.*)$ https://%1/$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] .



      Also -- try manually deleting all files in the core/cache directory. The disabled plugin may still be executing.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 53724
        • 15 Posts
        Quote from: BobRay at Jan 15, 2018, 11:30 PM
        It may not be causing your problem, but you should definitely uncomment one of these two sections:

        # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
        #RewriteCond %{HTTP_HOST} .
        #RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
        #RewriteRule ^(.*)$ https://%1/$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] .



        Also -- try manually deleting all files in the core/cache directory. The disabled plugin may still be executing.

        Hi Bob, thanks for the answer. I have deleted the files in the cache directory and also uncommented the first part of the section, since my website is located: http://localhost/modx , or should I have change smth inside? Well, nothing has changed, still the same problem.

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


        But I have enabled the error log for langrouter and i get this in the error.Log when I try to reach http://localhost/modx/sl/:
        [2018-01-16 08:02:27] (ERROR in LangRouter @ C:\wamp64\www\modx\core\components\langrouter\model\langrouter\langrouter.class.php : 154) Unhandled request:
        REQUEST_URI:   /modx/sl/
        REDIRECT_URI:  
        QUERY_STRING:  cultureKey=&q=sl/
        q:             sl/
        Context:       web
        Site start:    1
        [2018-01-16 08:02:27] (ERROR in LangRouter @ C:\wamp64\www\modx\core\components\langrouter\model\langrouter\langrouter.class.php : 171) contextmap: <pre class='xdebug-var-dump' dir='ltr'>
        <small>C:\wamp64\www\modx\core\components\langrouter\model\langrouter\langrouter.class.php:169:</small>
        <b>array</b> <i>(size=3)</i>
          'de' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'de'</font> <i>(length=2)</i>
          'en' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'en'</font> <i>(length=2)</i>
          'sl' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'web'</font> <i>(length=3)</i>
        </pre>


        or for http://localhost/modx/en/
        [2018-01-16 08:05:11] (ERROR in LangRouter @ C:\wamp64\www\modx\core\components\langrouter\model\langrouter\langrouter.class.php : 154) Unhandled request:
        REQUEST_URI:   /modx/en/
        REDIRECT_URI:  
        QUERY_STRING:  cultureKey=en&amp;q=
        q:             
        Context:       web
        Site start:    1
        [2018-01-16 08:05:11] (ERROR in LangRouter @ C:\wamp64\www\modx\core\components\langrouter\model\langrouter\langrouter.class.php : 171) contextmap: <pre class='xdebug-var-dump' dir='ltr'>
        <small>C:\wamp64\www\modx\core\components\langrouter\model\langrouter\langrouter.class.php:169:</small>
        <b>array</b> <i>(size=3)</i>
          'de' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'de'</font> <i>(length=2)</i>
          'en' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'en'</font> <i>(length=2)</i>
          'sl' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'web'</font> <i>(length=3)</i>
        </pre>

          • 3749
          • 24,544 Posts
          Sorry, I've never used Babel or Langrouter, so that was the extent of my ability to help on this one.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 53724
            • 15 Posts
            Quote from: BobRay at Jan 16, 2018, 04:54 PM
            Sorry, I've never used Babel or Langrouter, so that was the extent of my ability to help on this one.
            At least i got some feedback, thank you! Do you use any other tool / extras for internationalization in modx perhaps?
              • 3749
              • 24,544 Posts
              I don't, but a lot of people use MIGX-multilang and seem to like it. If you try something else, I'd recommend uninstalling and reverting all the Babel and Langrouter stuff, or (better), start with a new, clean install.

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 54320
                • 4 Posts
                LangRouter is a language routing plugin for MODx Revolution that is meant to be used with Babel. It takes care of switching contexts that hold the translations, depending on the URL requested by the client.