Skip to content

Commit

Permalink
Merge pull request #5 from mbrodala/patch-1
Browse files Browse the repository at this point in the history
[BUGFIX] Keep current protocol on redirects
  • Loading branch information
bednee committed Oct 20, 2014
2 parents 2847863 + 7bfdd13 commit 9af8925
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cooluri/link.Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,14 @@ public static function redirect($path,$status=0) {
$path = dirname($_SERVER['PHP_SELF']).'/'.$path;
}
$path = preg_replace('~^/~','',$path);
$path = 'http://'.$_SERVER['HTTP_HOST'].'/'.$path;
$path = preg_replace('~^/~','',$path);
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https';
} else {
$protocol = 'http';
}
$path = $protocol . '://'.$_SERVER['HTTP_HOST'].'/'.$path;
}
if (!empty($status)) {
header('Location: '.$path,true,$status);
Expand Down

0 comments on commit 9af8925

Please sign in to comment.