你应该看看这里:
private function getURIFromEnvironment($options)
{
$uri = $this->getOption($options, 'uri');
if (!$uri) { // use given URI in config options
if (isset($_SERVER['REDIRECT_URL']) && isset($_SERVER['SCRIPT_NAME'])) { // use redirection URL from Apache environment
$dirname = dirname($_SERVER['SCRIPT_NAME']);
$uri = substr($_SERVER['REDIRECT_URL'], strlen($dirname == DIRECTORY_SEPARATOR ? '' : $dirname));
} elseif (isset($_SERVER['REQUEST_URI'])) { // use request URI from environment
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
} elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) { // use PHP_SELF from Apache environment
$uri = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
} else { // fail
throw new \Exception('URI not provided');
}
}
具体来说:
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
我只是转储 $_SERVER 并查看可供您使用的内容并根据您的需要替换或添加。