You also need to make ALL your links served over HTTPS. And to ensure your app/management/config.php has the url with https://
Coded this for my framework, that both forces HTTPS and WWW if included in the website url.You can't use web.config to go to HTTPS and PHP wont know that you are on HTTPS or not because of the fact that the certificate is not on the server or so. I did get around this by writing some PHP code tho.
PHP:public function thisFullURL($enableSSL = NULL) { $serverName = $_SERVER['SERVER_NAME']; $uri = $_SERVER['REQUEST_URI']; 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://'; } $fullURL = $protocol.$serverName.$uri; $URL = $serverName.$uri; if ( $enableSSL && $protocol == 'http://' ) header("location: https://{$URL}"); else if( !$enableSSL && $protocol == 'https://' ) header("location: http://{$URL}"); else return $fullURL; }
Then you just have to pass true or false into the function true = SSL Redirection Enabled, false = SSL Redirection Disabled
public function forceUrl()
{
$url = self::url();
// Checks which protocol is used
$proto = explode('://', $url);
$proto = $proto[0];
// Checks if protocol should be forced
$protocheck = ($_SERVER['HTTP_X_FORWARDED_PROTO'] === $proto);
// Checks if www should be included
$iswwwset = (strstr($url, $proto . '://www.') ? "://www." : "://");
$wwwhost = (strstr($_SERVER['HTTP_HOST'], "www.") !== false);
$wwwcheck = ($iswwwset == "://www.") ? (!$wwwhost) : ($wwwhost);
if(!$protocheck || $wwwcheck) {
$redirect = $url . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
}
}