From 94bb1072e43495557c53d9ce376136f8e404f0c1 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Sat, 30 Sep 2023 17:22:10 +0100 Subject: [PATCH] Take current scheme (HTTP/S) in to account when redirecting. (#27) * Take current scheme (HTTP/S) in to account when redirecting. * Update test_redir.php Co-authored-by: Jonathan Champ --------- Co-authored-by: Eloy Lafuente Co-authored-by: Jonathan Champ --- test_redir.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test_redir.php b/test_redir.php index e2a1168..97e24c6 100644 --- a/test_redir.php +++ b/test_redir.php @@ -6,7 +6,11 @@ } // Redirect to full self URL. -$testurl = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME']; +$scheme = 'http'; +if (!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') !== 0) { + $scheme = 'https'; +} +$testurl = $scheme . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['SCRIPT_NAME']; // Determine if we require the final redirect to be an external destination. $extdest = isset($_GET['extdest']) ? '&extdest=' . $_GET['extdest'] : '';