Redirect incoming traffic based on referrer or random number
null coalesce does exist in php according to the google (per: https://stackoverflow.com/questions/1013493/coalesce-function-for-php )

$s = $_SERVER["HTTPS"] ?: "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;


I'm not super familiar with php, but I think this should work from what I understand you're doing here.