域名公共停靠页思路

V 阿呆 (UID: 1) 站长 [复制链接]
帖子链接已复制到剪贴板
帖子已经有人评论啦,不支持删除!

764 1

新建站点——新建index.php——粘贴下方代码——设置此站点为默认站点——关闭SSL

页面思路:其他人a解析到你的服务器,访问页面获取来访域名,将其显示在页面中;

                   给域名添加tk.xxx.xx的txt记录,值为mail-xxx@xx.xx,页面获取此域名的txt记录,并将记录中邮箱显示在页面中。

<?php
$currentDomain = $_SERVER['HTTP_HOST'];

if (strpos($currentDomain, 'www.') === 0) {
    $currentDomain = substr($currentDomain, 4);
}

$txtDomain = "tk." . $currentDomain;

$contactEmail = "未找到联系方式";

if (function_exists('dns_get_record')) {
    $records = dns_get_record($txtDomain, DNS_TXT);
    foreach ($records as $record) {
        if (isset($record['txt'])) {
            $txtValue = $record['txt'];
            if (preg_match('/mail-(.*)/', $txtValue, $matches)) {
                $contactEmail = $matches[1];
                break;
            }
        }
    }
}
?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $currentDomain; ?> 出售中</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f4f4f9;
            color: #333;
        }

        h1 {
            font-size: clamp(1.5rem, 5vw, 3rem);
            margin-bottom: 1rem;
        }

        p {
            font-size: clamp(1rem, 3vw, 1.5rem);
        }
    </style>
</head>
<body>
    <h1><?php echo $currentDomain; ?> 正在出售中</h1>
    <p>联系方式: <?php echo $contactEmail; ?></p>
</body>
</html>    

注释:设置默认站点后无需绑定域名,单方面解析即可。

本人发表的文字只是用来测试键盘是否可用,不代表本人立场
已有评论 ( 1 )
提示:您必须 登录 才能查看此内容。
创建新帖
自助推广点击空位自助购买TG联系
确认删除
确定要删除这篇帖子吗?删除后将无法恢复。
删除成功
帖子已成功删除,页面将自动刷新。
删除失败
删除帖子时发生错误,请稍后再试。