We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41787
    • 8 Posts
    Hello!
    I have the following issue and I am not sure how to solve it. I have a multilingual site and I have some tv which are of file type. When I am in the default language its link works ok. When I change the language the url is taking the cultureKey and therefore the link doesnt work. e.g. http://example.com/gr/filename.pdf

    In .htaccess file I have the following lines:

    # redirect all requests to /de/assets* and /nl/assets* to /assets*
    						RewriteCond %{REQUEST_FILENAME} !-d
    						RewriteCond %{REQUEST_FILENAME} !-f
    						RewriteRule ^(en|gr|de)/assets(.*)$ assets$2 [L,QSA]
    						 
    						# redirect all other requests to /en/* and /nl/*
    						# to index.php and set the cultureKey parameter
    						RewriteCond %{REQUEST_FILENAME} !-f
    						RewriteCond %{REQUEST_FILENAME} !-d
    						RewriteRule ^(en|gr|de)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]

    What am I doing wrong?

    Thanks for the help
    Dimitris
      • 3749
      • 24,544 Posts
      Since the language code will always be between slashes, and that won't happen anywhere else, you don't really need to match the beginning of the line.

      For the first one, try this (without the ^) :

      RewriteRule /(en|gr|de)/assets(.*)$ assets$2 [L,QSA]


      For the second one:

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


      If you want to be conservative (belt and suspenders), you can do this:

      RewriteRule ^.*/(en|gr|de)/assets(.*)$ assets$2 [L,QSA]
      RewriteRule ^.*/(en|gr|de)/(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
        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
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        If you are using Revolution, there are several routing plugins that don't use server rewrites at all.
          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
          • 41787
          • 8 Posts
          thanks a lot! problem solved!