en ese caso, la variable $_SERVER["HTTPS"] esta vacía o no inicializada:
Código PHP:
function sslpath(){
return "https://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
}
if($_SERVER["HTTPS"]==''){
$page=sslpath();
$lastpath=strrpos($page,"/");
$newpage=substr($page,0,$lastpath+1)."loginssl.php";
header("location: ".$newpage);
}