70 if ( $reload || is_null(self::$baseUri) ) {
71 $requestUri = isset($_SERVER[
'REQUEST_URI']) ? $_SERVER[
'REQUEST_URI'] : $_SERVER[
'PHP_SELF'];
72 $scriptName = $_SERVER[
'SCRIPT_NAME'];
73 $baseUri = strpos($requestUri, $scriptName) === 0 ? $scriptName : str_replace(
'\\',
'/', dirname($scriptName));
74 self::$baseUri = rtrim(
$baseUri,
'/');
85 public static function getUri( $reload =
false ) {
86 if ( $reload || is_null(self::$uri) ) {
88 if ( !empty($_SERVER[
'PATH_INFO']) ) {
89 $uri = $_SERVER[
'PATH_INFO'];
91 if ( isset($_SERVER[
'REQUEST_URI']) ) {
92 $uri = parse_url(self::getScheme() .
'://' . $_SERVER[
'HTTP_HOST'] . $_SERVER[
'REQUEST_URI'], PHP_URL_PATH);
93 }
else if ( isset($_SERVER[
'PHP_SELF']) ) {
94 $uri = $_SERVER[
'PHP_SELF'];
96 throw new RuntimeException(
'Unable to detect request URI');
99 if ( self::getBaseUri() !==
'' && strpos(
$uri, self::getBaseUri()) === 0 ) {
100 $uri = substr(
$uri, strlen(self::getBaseUri()));
102 self::$uri =
'/' . ltrim(
$uri,
'/');
113 if ( $reload || is_null(self::$scheme) ) {
114 self::$scheme = ( empty($_SERVER[
'HTTPS']) || $_SERVER[
'HTTPS'] ===
'off' ) ?
'http' :
'https';
125 if ( $reload || is_null(self::$queryString) ) {
126 self::$queryString = $_SERVER[
'QUERY_STRING'];