We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48390
    • 27 Posts
    I have been trying to figure out how to set up multilingual site with MODx and Babel. I'm pretty sure the contexts and the plugin are both set correctly but the .htaccess is probably causing me troubles. Here's what is looks like, I have the root set in a subfolder /test/voltage/admin2test and only one extra language (besides English) in /test/voltage/admin2test/cz/

    The /cz/ version, however, doesn't show and the page get's always redirected back to /test/voltage/admin2test/

    RewriteEngine On
    RewriteBase /test/voltage/admin2test/
    # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} !^my-domain\.cz [NC]
    #RewriteRule (.*) http://my-domain.cz/$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\.my-domain\.cz [NC]
    #RewriteRule (.*) http://www.my-domain.cz/$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]
    # The Friendly URLs part
    # detect language when requesting the root (/)
    #RewriteCond %{HTTP:Accept-Language} !^en [NC]
    #RewriteRule ^$ en/ [R=301,L]
    #RewriteRule ^$ cz/ [R=301,L]

    # redirect all requests to /cz/favicon.ico
    # to /favicon.ico
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(cz)/favicon.ico$ favicon.ico [L,QSA]

    # redirect all requests to /cz/assets* to /assets*
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(cz)/assets(.*)$ assets$2 [L,QSA]

    # redirect all other requests to /cz/*
    # to index.php and set the cultureKey parameter
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d [ed. note: filipc77 last edited this post 11 years, 5 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I much prefer to use a routing plugin that does not require .htaccess rewrite rules.

      https://gist.github.com/gadamiak/3812853
      https://gist.github.com/gadamiak/3812853#comment-1349670
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 13428 ☆ A M B ☆
        • 1,031 Posts
        It is available as package too (with permissions of Grzegorz/gadamiak): http://modx.com/extras/package/langrouter

        Issue tracker on https://github.com/Jako/LangRouter