BGFIX: #2587 Fix HTTPS detection on IIS (mackeyn)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63912 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2008-10-08 22:53:20 +00:00
parent 571e8d2b2c
commit e5f3982058
2 changed files with 4 additions and 4 deletions

View File

@ -26,7 +26,7 @@ class HTTP {
$urlBase = substr($_SERVER['PHP_SELF'], 0, -(strlen($_SERVER['SCRIPT_FILENAME']) - $commonLength));
$url = $urlBase . substr($filename, $commonLength);
$protocol = $_SERVER['HTTPS'] ? "https" : "http";
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? "https" : "http";
return "$protocol://". $_SERVER['HTTP_HOST'] . $url;
// Count the number of extra folders the script is in.

View File

@ -304,7 +304,7 @@ class Director {
}
}
$s = (isset($_SERVER['SSL']) || isset($_SERVER['HTTPS'])) ? 's' : '';
$s = (isset($_SERVER['SSL']) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')) ? 's' : '';
if(isset($_SERVER['HTTP_HOST'])) {
return "http$s://" . $_SERVER['HTTP_HOST'];
@ -511,7 +511,7 @@ class Director {
* </code>
*/
static function forceSSL() {
if(!isset($_SERVER['HTTPS']) && !Director::isDev()) {
if((!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && !Director::isDev()) {
$destURL = str_replace('http:', 'https:', Director::absoluteURL($_SERVER['REQUEST_URI']));
header("Location: $destURL", true, 301);
@ -524,7 +524,7 @@ class Director {
*/
static function forceWWW() {
if(!Director::isDev() && !Director::isTest() && strpos($_SERVER['SERVER_NAME'], 'www') !== 0) {
if(!empty($_SERVER['HTTPS'])) {
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$destURL = str_replace('https://', 'https://www.', Director::absoluteURL($_SERVER['REQUEST_URI']));
} else {
$destURL = str_replace('http://', 'http://www.', Director::absoluteURL($_SERVER['REQUEST_URI']));