此脚本是一个函数,用于定义站点 URL 以将其发送到大脚本,但由于它是共享托管的,因此它获得了不正确的路径,如何告诉它正确的站点路径?我想直接告诉它站点网址和脚本目录,脚本认为这是路径,但正确的路径只是。我想删除,因为是共享主机路径/hermes/bosnaweb23a/index.php/index.php/hermes/bosnaweb23a//hermes/bosnaweb23a/
<?php
function home_base_url(){
$base_url = (isset($_SERVER['HTTPS']) &&
$_SERVER['HTTPS']!='off') ? 'https://' : 'http://';
$tmpURL = dirname(__FILE__);
$tmpURL = str_replace(chr(92),'/',$tmpURL);
$tmpURL = str_replace($_SERVER['DOCUMENT_ROOT'],'',$tmpURL);
$tmpURL = ltrim($tmpURL,'/');
$tmpURL = rtrim($tmpURL, '/');
if (strpos($tmpURL,'/')){
$tmpURL = explode('/',$tmpURL);
$tmpURL1 = $tmpURL[0];
$tmpURL2 = $tmpURL[1];
$tmpURL = $tmpURL1;
if(!empty($tmpURL2)) $tmpURL .= '/'.$tmpURL2;
}
if ($tmpURL !== $_SERVER['HTTP_HOST'])
$base_url .= $_SERVER['HTTP_HOST'].'/'.$tmpURL.'/';
else
$base_url .= $tmpURL.'/';
$base_url = str_replace('//','/',$base_url);
$base_url = str_replace('http:/','http://',$base_url);
$base_url = str_replace('https:/','https://',$base_url);
return str_replace(dirname(__FILE__),'',$base_url);
}
$local_path = dirname(__FILE__).'/';
$sSoftware = strtolower( $_SERVER["SERVER_SOFTWARE"] );
function getSlashes() {
$sSoftware = strtolower( $_SERVER["SERVER_SOFTWARE"] );
if ( strpos($sSoftware, "microsoft-iis") !== false ) return "\\";
else return "/";
}
if ( strpos($sSoftware, "microsoft-iis") !== false ) {
$local_path = str_replace(getSlashes(), '/', dirname(__FILE__)).'/';
}
function get_domain() {
return $_SERVER['HTTP_HOST'];
}
慕工程0101907