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.I put that on index.php, I get 'Redirect too many times' @Core
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;
}
No reason for that whole function @Zaka provided, if you KNOW you're going to force HTTPS.Put the function on index.php ? So I have to run the function ? @Zaka
if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
When using cloudflares SSL certificate u can't just check if HTTPS is on or off. Thats why you have to check for headers + I was using that function for more than just SSLNo reason for that whole function @Zaka provided, if you KNOW you're going to force HTTPS.
But yeah, put this in the global.php and not the index.php file.PHP:if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){ $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $redirect); exit(); }
There's a fix for forcing HTTPS in web.config, you all just didn't research enough.
Nah, that's pretty obvious, because the Flexible SSL is not a SSL hosted on the webserver, which means it doesn't work that way, and isn't even referred to as a real SSLWhen using cloudflares SSL certificate u can't just check if HTTPS is on or off. Thats why you have to check for headers + I was using that function for more than just SSL
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
if (!(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' ||
$_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
{
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
The reason why the https is gray, is because you're including http sources, e.g images, css / js files.@Sentinel @Zaka I am using this from stackoverflow, work fine:
But sometimes after I log onto my account, the https is gray and no [SECURE] tag. Only from index page. I apply this code on index.php so It would apply to all page ?Code:if (!(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) { $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $redirect); exit(); }
Mixed Content: The page at 'https://playprevs.com/me' was loaded over HTTPS, but requested an insecure image 'http://playrise.me/web-gallery/images/icon_habbo_small.png'. This content should also be served over HTTPS.
No shit, but can't you read or what? You're including a HTTP image source from PLAYRISE. Read the damn error ffs.