Skip to content

Commit

Permalink
Take current scheme (HTTP/S) in to account when redirecting. (#27)
Browse files Browse the repository at this point in the history
* Take current scheme (HTTP/S) in to account when redirecting.

* Update test_redir.php

Co-authored-by: Jonathan Champ <[email protected]>

---------

Co-authored-by: Eloy Lafuente <[email protected]>
Co-authored-by: Jonathan Champ <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2023
1 parent ebcedd9 commit 94bb107
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test_redir.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : '';
Expand Down

0 comments on commit 94bb107

Please sign in to comment.