@@ -38,6 +38,8 @@ public static function getRequest() {
38
38
public $ uri ;
39
39
/** The path of the request. Does not include parameters */
40
40
public $ path ;
41
+ /** The path of the original request (requested at proxy). Does not include parameters */
42
+ public $ originalPath ;
41
43
/** The path split in its elements */
42
44
public $ pathElements ;
43
45
/** The parameters as a string */
@@ -89,6 +91,7 @@ public function __construct() {
89
91
$ this ->body = NULL ;
90
92
$ this ->documentRoot = $ this ->initDocumentRoot ();
91
93
$ this ->webRoot = $ this ->initWebRoot (TRUE );
94
+ $ this ->originalPath = $ this ->initOriginalPath ();
92
95
$ this ->localWebRoot = $ this ->initWebRoot (FALSE );
93
96
$ this ->webRootUri = $ this ->initWebRootUri ();
94
97
$ this ->appRoot = $ this ->documentRoot ;
@@ -285,7 +288,24 @@ protected function initDocumentRoot() {
285
288
}
286
289
return $ _SERVER ['DOCUMENT_ROOT ' ];
287
290
}
288
-
291
+
292
+ /**
293
+ * Returns the original path as request by the end user.
294
+ * The path might be different from $this->path as
295
+ * a webroot mapping might be involved.
296
+ */
297
+ protected function initOriginalPath () {
298
+ $ rc = $ this ->path ;
299
+ $ rootDef = $ _SERVER ['HTTP_X_FORWARDED_ROOT ' ];
300
+ if ($ rootDef ) {
301
+ $ arr = explode (', ' , $ rootDef );
302
+ if (strpos ($ rc , $ arr [0 ]) === 0 ) {
303
+ $ rc = $ arr [1 ].substr ($ rc , strlen ($ arr [0 ]));
304
+ }
305
+ }
306
+ return $ rc ;
307
+ }
308
+
289
309
/**
290
310
* Returns the web root - that is the web path where the current
291
311
* script is rooted and usually the base path for an application.
0 commit comments