From 426e70bbd79af6979ff3d520885305939b0cb52e Mon Sep 17 00:00:00 2001 From: Iain MacDonald Date: Thu, 26 Dec 2013 21:54:21 +0800 Subject: 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) --- includes/session.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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))); -- cgit v1.3