We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    I set up my multiple context environment using the switch-statement method described at http://www.h-quadrat.com/techblog/111-modx-revolution-multi-domain-context-installation-english.php.

    Initially I had just set up one additional context. It looks like this:


    And my switch statement in index.php looked like this:

    switch(strtolower(MODX_HTTP_HOST)) {
       case 'dev.uwsa.edu:80':
       case 'dev.uwsa.edu':
          $modx->initialize('myuwsa');
          break;
       case 'wwwnew.uwsa.edu:80':
       case 'wwwnew.uwsa.edu':
          $modx->initialize('web');
          break;
       default:
          // by default / if no other rule can be applied, load 'web' context
          $modx->initialize('web');
          break;
    }
    


    and everything worked just as it should. But last week I tried to add a third context, with these parameters:


    I added a new section to the switch statement:
    switch(strtolower(MODX_HTTP_HOST)) {
       case 'dev.uwsa.edu:80':
       case 'dev.uwsa.edu':
          $modx->initialize('myuwsa');
          break;
       case 'itmc.wisconsin.edu:80':
       case 'itmc.wisconsin.edu':
          $modx->initialize('ITMC');
          break;
       case 'wwwnew.uwsa.edu:80':
       case 'wwwnew.uwsa.edu':
          $modx->initialize('web');
          break;
       default:
          // by default / if no other rule can be applied, load 'web' context
          $modx->initialize('web');
          break;
    }
    


    I expected this to work, but it isn’t. When I request a page via http://itmc.wisconsin.edu, the value of MODX_HTTP_HOST is still ’wwwnew.uwsa.edu’, even though I have an http_host key set up in the ITMC context. So only resources that exist in my web context will load via that hostname.

    Is this a bug? Should I just whack this context and try again? Or am I doing something wrong with my configuration?
      • 14883 ☆ A M B ☆
      • 450 Posts
      Nevermind. This was all on my end. I have an ’auto_prepend_file’ defined in my php.ini file, which hooks in to my old crappy template system. Forgot that I have to add a line to that file for each MODx host, to break them out of that code. Did that, and now the context works as expected.