改进Request类的root方法

This commit is contained in:
thinkphp
2016-05-20 16:28:25 +08:00
parent 1ad2f7af31
commit b67e98ad2b

View File

@@ -288,7 +288,11 @@ class Request
$this->root = $url;
return;
} elseif (!$this->root) {
$this->root = rtrim(str_replace('\\', '/', dirname($this->baseFile())), '/');
$file = $this->baseFile();
if (0 !== strpos($this->url(), $file)) {
$file = str_replace('\\', '/', dirname($file));
}
$this->root = rtrim($file, '/');
}
return true === $url ? $this->domain() . $this->root : $this->root;
}