提交 8623200e 编写于 作者: D Devil

根目录截取优化

上级 89f486a1
......@@ -35,7 +35,17 @@ define('__MY_HTTP__', (
) ? 'https' : 'http');
// 根目录
$my_root = empty($_SERVER['SCRIPT_NAME']) ? '' : substr($_SERVER['SCRIPT_NAME'], 1, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$my_root = '';
if(!empty($_SERVER['SCRIPT_NAME']))
{
$index_pos = strpos($_SERVER['SCRIPT_NAME'], 'index.php');
if($index_pos !== false)
{
$my_root = substr($_SERVER['SCRIPT_NAME'], 1, $index_pos-1);
} else {
$my_root = substr($_SERVER['SCRIPT_NAME'], 1, strrpos($_SERVER['SCRIPT_NAME'], '/'));
}
}
define('__MY_ROOT__', defined('IS_ROOT_ACCESS') ? $my_root : str_replace('public'.DS, '', $my_root));
define('__MY_ROOT_PUBLIC__', defined('IS_ROOT_ACCESS') ? DS.$my_root.'public'.DS : DS.$my_root);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册