We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16942
    • 33 Posts
    I've just done a long, stepped upgrade process (a bit like https://forums.modx.com/thread/103007/upgrade-from-2-0-8#dis-post-554616) from 2.3.1 through each and every minor version all the way to 2.5.8.

    Mostly everything survived except that I have two sites (and hence two contexts) running off the same modx installation and for some reason the second site is now displaying only content from the first site. Maddening - I don't know where in the long process this started happening.

    My context properties have not changed. So what else could I be exploring to get this working again?

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

      • 3749
      • 24,544 Posts
      Do you know how the routing was being done (iow, how were users directed to the correct site)?

      Make sure you have an uncached (with the exclamation point) site_url tag in the head section of all templates:

      <base href="[[!++site_url]]" />
        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
        • 16942
        • 33 Posts
        Quote from: BobRay at Oct 31, 2017, 08:08 PM
        Do you know how the routing was being done (iow, how were users directed to the correct site)?

        Make sure you have an uncached (with the exclamation point) site_url tag in the head section of all templates:

        <base href="[[!++site_url]]">

        Goodness knows - there was another domain name pointing at the virtual server and in the context settings for the second site, I set up the correct values for http_host, site_url, Site start, base_url and site name.

        Could there have been additional config in an .htaccess which has since been overwritten?
        • discuss.answer
          • 16942
          • 33 Posts
          Right, I have an answer on this and I want to post it so that others can benefit.

          It looks like the index.php in the site root got overwritten. There are settings in there which are needed in order for this to work.

          Specificially you need to comment out (add // to the line starting $modx->
          /* Initialize the default 'web' context */
          $modx->initialize('web');


          Below it, you need to write a switch to match the incoming hostname and then initialise the right site context, so I inserted

          /* setup for multiple domains */
          switch(strtolower(MODX_HTTP_HOST)) {
             case 'www.myothersite.com:80':
             case 'myothersite.com:80':
             case 'myothersite.com':
             case 'www.myothersite.com':
                // if the http_host is myothersite.com switch the context to the other site
                $modx->initialize('web2');
                break;
            default:
                // by default / if no other rule can be applied, load 'web' context
                $modx->initialize('web');
                break;
          }
          
          


          TBH this has never seemed a very efficient method but it seems to work
            • 3749
            • 24,544 Posts
            I don't think it's inefficient. MODX has to be initialized on every request, so you're just initializing the correct context.
              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