diff options
| author | Iain MacDonald <IJMacD@gmail.com> | 2013-12-26 21:54:21 +0800 |
|---|---|---|
| committer | Iain MacDonald <IJMacD@gmail.com> | 2013-12-26 21:54:21 +0800 |
| commit | 426e70bbd79af6979ff3d520885305939b0cb52e (patch) | |
| tree | 32d7888c380a48f31132147662ef966018183280 | |
| parent | 33a3adad1db5234f1430dd604477e65f451d0d53 (diff) | |
| download | webtrees-426e70bbd79af6979ff3d520885305939b0cb52e.tar.gz webtrees-426e70bbd79af6979ff3d520885305939b0cb52e.tar.bz2 webtrees-426e70bbd79af6979ff3d520885305939b0cb52e.zip | |
Fixed redirection bug
In the case of MOD_REWRITE being used on an Apache server to forge the webtrees url,
webtrees would try to redirect to its source directory path and would not respect
the SERVER_URL site setting (causing an infinite redirect loop)
| -rwxr-xr-x | includes/session.php | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/includes/session.php b/includes/session.php index 026ff9332d..5a950d41ca 100755 --- a/includes/session.php +++ b/includes/session.php @@ -168,9 +168,12 @@ define('WT_SERVER_NAME', (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT']==80 ? '' : ':'.$_SERVER['SERVER_PORT']) ); +// REDIRECT_URL should be set in the case of Apache following a RedirectRule // SCRIPT_NAME should always be correct, but is not always present. // PHP_SELF should always be present, but may have trailing path: /path/to/script.php/FOO/BAR -if (!empty($_SERVER['SCRIPT_NAME'])) { +if (!empty($_SERVER['REDIRECT_URL'])) { + define('WT_SCRIPT_PATH', substr($_SERVER['REDIRECT_URL'], 0, stripos($_SERVER['REDIRECT_URL'], WT_SCRIPT_NAME))); +} elseif (!empty($_SERVER['SCRIPT_NAME'])) { define('WT_SCRIPT_PATH', substr($_SERVER['SCRIPT_NAME'], 0, stripos($_SERVER['SCRIPT_NAME'], WT_SCRIPT_NAME))); } elseif (!empty($_SERVER['PHP_SELF'])) { define('WT_SCRIPT_PATH', substr($_SERVER['PHP_SELF'], 0, stripos($_SERVER['PHP_SELF'], WT_SCRIPT_NAME))); |
