From 05e0b1d518cfb25a1451e25e2794ded632cca33f Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 26 Sep 2023 22:11:12 +0100 Subject: [PATCH 1/2] Take current scheme (HTTP/S) in to account when redirecting. --- test_redir.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test_redir.php b/test_redir.php index e2a1168..fb07778 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'] : ''; From 9ee051b0b05f869e61333e1783978c4d8c575b93 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Sat, 30 Sep 2023 18:12:51 +0200 Subject: [PATCH 2/2] Update test_redir.php Co-authored-by: Jonathan Champ --- test_redir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_redir.php b/test_redir.php index fb07778..97e24c6 100644 --- a/test_redir.php +++ b/test_redir.php @@ -10,7 +10,7 @@ if (!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') !== 0) { $scheme = 'https'; } -$testurl = $scheme.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME']; +$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'] : '';