// 检查网址是否包含"ac.94zhe.ltd"
$current_url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if (strpos($current_url, "ac.94zhe.ltd") !== false) {
    // 检查是否已经重定向过
    if (!isset($_SESSION['redirected'])) {
        $_SESSION['redirected'] = true;

        // 生成随机域名
        $domain = generateRandomDomain();

        // 获取当前请求的参数
        $parameters = $_SERVER['QUERY_STRING'];

        // 构建重定向URL
        $redirect_url = "http://" . $domain . "/app/index.php?" . $parameters; // 替换为你的重定向URL路径

        // 发起重定向
        header("Location: " . $redirect_url);
        exit(); // 终止后续输出
    }
}


// 生成随机域名的函数
function generateRandomDomain() {
    $allowed_chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
    $random_string = '';
    $length = 13; // 生成域名的长度

    // 生成随机字符串
    for ($i = 0; $i < $length; $i++) {
        $random_string .= $allowed_chars[rand(0, strlen($allowed_chars) - 1)];
    }

    // 拼接域名
    $domain = $random_string . ".ad.94zhe.ltd"; // 可以根据需要更改后缀

    return $domain;
}

上述代码使用了 $_SESSION 变量来判断是否已经进行过重定向。在第一次重定向后,会将 $_SESSION['redirected'] 设置为 true,这样在后续的请求中就不会再进行重定向。请确保在使用 $_SESSION 变量之前已经调用了 session_start() 函数

检查网址是否包含ac94zheltd $current_url = $_SERVERHTTP_HOST $_SERVERREQUEST_URI; if strpos$current_url ac94zheltd !== false 生成随机域名 $domain = generateRandomDomain; 获取当前请求的参数

原文地址: https://www.cveoy.top/t/topic/hRRw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录