We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42701
    • 47 Posts
    I'm following ModX: The Official Guide Ch9: Site Organization and Contexts, trying to create two contexts in the same ModX install. I'm using two different domains on the same server, call them www.aaa.com and www.bbb.com. www.aaa.com already exists and has the ModX install in it. www.bbb.com is in its own vhosts folder, and has index.php and config.core.php from www.aaa.com copied to its root, as per the instructions in the book. Problem is, www.bbb.com keeps throwing a 503 error. I've tracked it down to this code in index.php:

    /* include the modX class */
    if (!@include_once (MODX_CORE_PATH . "/model/modx/modx.class.php")) {
    $errorMessage = 'Site temporarily unavailable';
    @include(MODX_CORE_PATH . 'error/unavailable.include.php');
    header('HTTP/1.1 503 Service Unavailable');
    echo "<html><title>Error 503: Site temporarily unavailable</title><body><h1>Error 503</h1><p>{$errorMessage}</p$
    exit();
    }

    In other words, it's not able to include the modx.class.php file from aaa.com. I did a die statement on `MODX_CORE_PATH . "/model/modx/modx.class.php"` on both sites and they come back with the same path. Is this a CORS issue? I've tried adding an AC Allow Origin header to both files in www.bbb.com to no avail. Any help would be greatly appreciated.

    Thanks!
      • 3749
      • 24,544 Posts
      Make sure the path in config.core.php is a full path rather than a relative one.

      Also, on the bbb.com site, check the paths and URLs in the core/config/config.inc.php file.
        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
        • 42701
        • 47 Posts
        Hi Bob,

        The config.core.php file does have a full path. There is no core/config/config.inc.php file however. I am trying to emulate what you did in Ch 9 of MODX: The Official Guide, in the Two Contexts, Two Directories section. So the only contents in the httpdocs folder of bbb.com are index.php and config.core.php, copied from aaa.com!
          • 3749
          • 24,544 Posts
          It could possibly be a CORS issue. I tested it on localhost where that probably wouldn't be an issue. TBH, I tend to avoid using multiple front-end contexts if at all possible, just because of issues like this.


          In theory, if that config.core.php file is correct (which it must be if the other site works), the index.php file should find the MODX class file with no trouble. You might try taking out the @ and making it 'require_once' instead of 'include' to see if you get a more meaningful error message. Also, adding this just above that line would tell you if the core path is getting through:

          echo '<h3>MODX CORE PATH: ' . MODX_CORE_PATH . '</h3>';


          [ed. note: BobRay last edited this post 11 years, 6 months ago.]
            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
            echo '<h3>MODX CORE PATH: ' . MODX_CORE_PATH . '</h3>';
              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
              • 42701
              • 47 Posts
              Quote from: BobRay at Mar 31, 2015, 12:27 AM
              It could possibly be a CORS issue. I tested it on localhost where that probably wouldn't be an issue. TBH, I tend to avoid using multiple front-end contexts if at all possible, just because of issues like this.


              In theory, if that config.core.php file is correct (which it must be if the other site works), the index.php file should find the MODX class file with no trouble. You might try taking out the @ and making it 'require_once' instead of 'include' to see if you get a more meaningful error message. Also, adding this just above that line would tell you if the core path is getting through:

              echo '<h3>MODX CORE PATH: ' . MODX_CORE_PATH . '</h3>';



              Thanks guys,

              I tried removing the @ sign, and it turns out it's an open_base_dir issue. I gave bbb.com access to aaa.com and now it's working!
                • 3749
                • 24,544 Posts
                I'm glad to hear you got it sorted. Thanks for reporting back. 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