We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Here is a new attempt at this algorithm; David can you see if this works for you? I’ll also try and get Susan to try this on her PHP-CGI installation...this goes after the https_port variable and before the constants, replacing the existing if clause...

    [NOTE: UPDATED AFTER INITIAL TESTS FROM DAVID]
    if (empty ($base_path) || empty ($base_url) || $_REQUEST['base_path'] || $_REQUEST['base_url']) {
        $sapi= php_sapi_name();
        if (strpos($sapi, 'cgi') === 0) {
            $script_name= $_SERVER['PHP_SELF'];
        } else {
            $script_name= $_SERVER['SCRIPT_NAME'];
        }
        $a= explode("/manager", str_replace("\\", "/", dirname($script_name)));
        if (count($a) > 1)
            array_pop($a);
        $url= implode("manager", $a);
        reset($a);
        $a= explode("manager", str_replace("\\", "/", dirname(__FILE__)));
        if (count($a) > 1)
            array_pop($a);
        $pth= implode("manager", $a);
        unset ($a);
        $base_url= $url . (substr($url, -1) != "/" ? "/" : "");
        $base_path= $pth . (substr($pth, -1) != "/" && substr($pth, -1) != "\\" ? "/" : "");
    
        // assign site_url
        $site_url= ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port) ? 'https://' : 'http://';
        $site_url .= $_SERVER['HTTP_HOST'];
        if ($_SERVER['SERVER_PORT'] != 80)
            $site_url= str_replace(':' . $_SERVER['SERVER_PORT'], '', $site_url); // remove port from HTTP_HOST 
        $site_url .= ($_SERVER['SERVER_PORT'] == 80 || (isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port) ? '' : ':' . $_SERVER['SERVER_PORT'];
        $site_url .= $base_url;
    }


    Let me know if you have any success with this or not, or if you have any questions or problems trying it out. If you can, please try with and without friendly url/.htaccess redirection. You can also add the following after the code above to see what the calculations are when various URLs are requested:
    [NOTE: UPDATED THIS TO INCLUDE THE SAPI VALUE TOO!]
    echo '<pre>php_sapi_name() = ' . $sapi . '</pre>';
    echo '<pre>' . print_r($_SERVER, 1) . '</pre>'; 
    echo '<pre>base_path = ' . $base_path . '</pre>'; 
    echo '<pre>base_url = ' . $base_url . '</pre>'; 
    echo '<pre>site_url = ' . $site_url . '</pre>'; 
    die();
    

    If you do encounter problems, add this code and send me a PM with the results of this output.
      • 6726
      • 7,075 Posts
      Just got back home... I’ll try this ASAP and report !
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l&#39;outil id
        • 6726
        • 7,075 Posts
        Just finished testing the new config file... I do get a blank page no matter which URL I type, no matter if clean urls are on or not.

        Here is a text file with the output in each case : home, manager and sub page with and without clean urls.

        Hope it helps !
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l&#39;outil id
          • 22303 MODX Staff
          • 10,725 Posts
          Thanks much David! That revealed the problems to me. I’m updating the code in the post if you could try one more time for me... wink
            • 6726
            • 7,075 Posts
            Great !

            Went to bed and got some sleep, but I am back and refreshed, I’ll test that right now smiley
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l&#39;outil id
              • 6726
              • 7,075 Posts
              And back : no luck still blank pages though the output has the right site_url now smiley

              Here is the second report, I didn’t test query strings, had to do fast I have a client working on content on the test site undecided
              If you need more info, I’ll do a fresh demo install to continue further...
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 25663 MODX Staff
                • 12,272 Posts
                David could you set up a test site and give Jason FTP access as well? Would make getting to the bottom of this much much faster.
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: davidm at Apr 20, 2007, 04:19 AM

                  And back : no luck still blank pages though the output has the right site_url now smiley

                  Here is the second report, I didn’t test query strings, had to do fast I have a client working on content on the test site undecided
                  If you need more info, I’ll do a fresh demo install to continue further...

                  Well, that code is now doing it’s job properly again, so whatever the blank page issue is, it’s not because of those paths any more. You likely just need to clear the cache of the bad paths...
                    • 6726
                    • 7,075 Posts
                    Ok Jason I’ll see to it that everything is "reset" properly : cache, session cookies and all and test again !
                    Thanks for the fix grin
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l&#39;outil id
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Susan,

                      Could you test on the domains that were having problems and report back, using Jason’s latest tweak to the code? Thanks!
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me