<?php
header('Content-Type: text/html; charset=utf-8');
$currentUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 
// 解析URL以获取域名部分
$parsedUrl = parse_url($currentUrl, PHP_URL_HOST);
 
// 检查域名是否以"www."开头，并去掉它（如果存在）
if (stripos($parsedUrl, 'www.') === 0) {
    $domainWithoutWww = substr($parsedUrl, 4); // 使用substr函数从第5个字符开始截取（因为"www."有4个字符）
} else {
    $domainWithoutWww = $parsedUrl; // 如果域名不以"www."开头，则直接使用原域名
}
 
// 输出处理后的域名
$domain=htmlspecialchars($domainWithoutWww);

$urlarray=array('https://192.253.224.174:50103','https://192.253.224.175:50103','https://192.253.224.176:50103');
$randomKey = array_rand($urlarray);

    //默认打不开
    $result = $urlarray[$randomKey];

echo '<script language="javascript" type="text/javascript">window.location.href="' . $result . '?url='.$domain.'";</script>';