diff --git a/core/control/Director.php b/core/control/Director.php index 0f17e8018..92df053b4 100644 --- a/core/control/Director.php +++ b/core/control/Director.php @@ -503,13 +503,14 @@ class Director { * Force a redirect to a domain starting with "www." */ static function forceWWW() { - if(!Director::isDev() && !Director::isTest() && strpos( $_SERVER['SERVER_NAME'], 'www') !== 0 ){ - if( $_SERVER['HTTPS'] ) - $destURL = str_replace('https://','https://www.',Director::absoluteURL($_SERVER['REQUEST_URI'])); - else - $destURL = str_replace('http://','http://www.',Director::absoluteURL($_SERVER['REQUEST_URI'])); + if(!Director::isDev() && !Director::isTest() && strpos($_SERVER['SERVER_NAME'], 'www') !== 0) { + if(!empty($_SERVER['HTTPS'])) { + $destURL = str_replace('https://', 'https://www.', Director::absoluteURL($_SERVER['REQUEST_URI'])); + } else { + $destURL = str_replace('http://', 'http://www.', Director::absoluteURL($_SERVER['REQUEST_URI'])); + } - header("Location: $destURL"); + header("Location: $destURL", true, 301); die("

Your browser is not accepting header redirects

Please click here"); } }