We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38142
    • 91 Posts
    I have set up a second context to use for an Arabic version of an English website so that the English version uses this URL: https://www.haram-alaqsa.com and the Arabic version uses this URL: https://www.haram-alaqsa.com/ar/ without creating a physical ar folder on the server for duplicate css, js files, etc. Following the instructions of lx here:

    https://forums.modx.com/thread/?thread=51346&i=1&page=2

    Problem: All pages of both contexts load except the home page of the second (Arabic) context. The home page throws this error in the browser:

    [HTTP/1.1 301 Moved Permanently 3153ms]

    So maybe an htaccess problem. But I can't see where the problem is. Any help?

    Context settings for the Arabic context are:

    Key: Arabic
    cultureKey: ar
    rb_base_url: https://www.haram-alaqsa.com/
    site_start: 48
    site_url: https://www.hara-alaqsa.com/ar/

    The gateway plugin is:

    if ( $modx->context->get( 'key' ) != 'mgr') {
        $cntxt_param = $modx->getOption('context_param_alias', null, 'c');
        if ( isset( $_REQUEST[$cntxt_param] ) && $_REQUEST[$cntxt_param] != '' ) {
          switch ( $_REQUEST[$cntxt_param] ) {
               
            case 'en':
              $modx->switchContext('web');
              $modx->setOption('cultureKey', 'en');
              break;
               
            case 'ar':
              $modx->switchContext('Arabic');
              $modx->setOption('cultureKey', 'ar');
              break;
               
            default:
              $modx->switchContext('web');
              $modx->setOption('cultureKey', 'en');
              break;
          }
        }
      }


    And what I guess is the crucial bit of the htaccess file is here (3rd and 4th lines added for the autoSSL certificate):

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    
    RewriteRule ^(en|ar)?(\/)?(.*)$ index.php?c=$1&q=$3 [L,QSA]


    Any help spotting what is stopping the home page of the second context load?

    This question has been answered by cottagestuff. See the first response.

    [ed. note: cottagestuff last edited this post 8 years, 8 months ago.]
    • discuss.answer
      • 38142
      • 91 Posts
      If anyone else is in the same boat and has also been banging his/her head against the MODX brick wall for three days, descending to a trough of despair when the two crucial tutorial pages are now displaying as ads for: A) a bus service for the elderly in Hong Kong, and, B) Chinese lingerie, some progress can be achieved by following lokomaya's advice here:

      https://forums.modx.com/thread/?thread=51346&i=1&page=5

      i.e.

      No Babel
      No gateway plugin
      Settings for the second context as lokomaya describes
      Create a physical directory for the second context
      Alter the index.php file as lokomaya says, and upload to new directory
      Create new .htaccess file for new directory as for root but with these additions (here the directory is called /ar/ and the home page for the site has the alias: alaqsa):

      RewriteEngine On
      RewriteBase /ar/
      
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^assets(.*)$ https://www.haram-alaqsa.com/assets$1 [L,QSA]
      
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^css(.*)$ https://www.haram-alaqsa.com/css$1 [L,QSA]
      
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^js(.*)$ https://www.haram-alaqsa.com/js$1 [L,QSA]
      
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^img(.*)$ https://www.haram-alaqsa.com/img$1 [L,QSA]
      
      
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^photos(.*)$ https://www.haram-alaqsa.com/photos$1 [L,QSA]
      
      #FURL
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
      
      #Desperate attempt to solve the non-loading-homepage problem
      RewriteRule ^ar/$  https://www.haram-alaqsa.com/ar/alaqsa.html [R=301,L]


      Not ideal, but stuff is working. Except the page with getResources on, which is now throwing a 500 Internal Server Error. More head-banging.



        • 3749
        • 24,544 Posts
        500 errors sometimes come from .htaccess issues. Does that page trigger any special rewrite rules?

        Another possibility is a circular reference where the getResources call pulls page containing the getResources tag, though that wouldn't usually lead to a 500 error.
          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
          • 38142
          • 91 Posts
          Bob, thank you for that. Difficult to explain briefly, but seems to have been due to the time of year. The code worked in December, but not January. The snippet looks first for dated resources before triggering getResources, but I had not allowed for the eventuality that there might be no resources for the current year.

          Thanks again.
            • 3749
            • 24,544 Posts
            I'm glad you got it sorted. smiley
              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