Redirection fix

Redirection worked fine as long as the server was using HTTP. HTTPS was
a different matter entirely. Location headers will now be sent with full
protocol, server name and port.
This commit is contained in:
Emmanuel BENOîT 2012-02-06 15:06:16 +01:00
parent 62a4d0a391
commit c73baa8488

View file

@ -11,6 +11,9 @@ abstract class Page
public function __construct( )
{
$this->baseURL = dirname( $_SERVER[ 'SCRIPT_NAME' ] );
if ( $this->baseURL == '/' ) {
$this->baseURL = '';
}
}
public final function addController( Controller $controller )
@ -52,6 +55,8 @@ abstract class Page
if ( $rc{0} != '/' ) {
$rc = $this->baseURL . '/' . $rc;
}
$rc = ( $_SERVER[ 'HTTPS' ] ? 'https' : 'http' ) . '://' . $_SERVER[ 'SERVER_NAME' ]
. ':' . $_SERVER[ 'SERVER_PORT' ] . $rc;
header( "Location: $rc" );
$rv = true;
}