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.