diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index a91a673f6..d3079e119 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -609,11 +609,7 @@ * @brief 요청이 들어온 URL에서 argument를 제거하여 return **/ function getRequestUri() { - $hostname = $_SERVER['HTTP_HOST']; - //$port = $_SERVER['SERVER_PORT']; - //if($port!=80) $hostname .= ":{$port}"; - $path = str_replace('index.php','',$_SERVER['SCRIPT_NAME']); - return sprintf("http://%s%s",$hostname,$path); + return sprintf("http://%s%s",$_SERVER['HTTP_HOST'], getScriptPath()); } /** diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index 201e6c50c..dd6ddfbc6 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -86,7 +86,7 @@ function display($content) { $content .= $this->_debugOutput(); - $path = str_replace('index.php','',$_SERVER['SCRIPT_NAME']); + $path = getScriptPath(); // commons/modules/files/widgets/layouts/addons 로 시작되는 src나 href의 값을 절대경로로 변경 $content = preg_replace('!(href|src)=("|\'){0,1}(commons|modules|widgets|layouts|addons|files)!is', '\\1=\\2'.$path.'\\3', $content); diff --git a/config/func.inc.php b/config/func.inc.php index e0100c5fa..f1f7d39dc 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -463,4 +463,11 @@ return sprintf("%08lx%08lx", $nr, $nr2); } + /** + * 현재 요청받은 스크립트 경로를 return + **/ + function getScriptPath() { + if(function_exists('php_sapi_name') && php_sapi_name()=='cgi') return preg_replace('/index.php/i','',$_SERVER['PATH_INFO']); + return preg_replace('/index.php/i','',$_SERVER['SCRIPT_NAME']); + } ?>