<?php
/**
* 根据用户代理判断访问者是否为搜索引擎蜘蛛
* 如果是蜘蛛则加载WordPress环境,否则显示index.html
*/
// 获取用户代理字符串
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
// 定义搜索引擎蜘蛛的关键词
$spiders = [
'googlebot', // Google
'baiduspider', // 百度
'bingbot', // 必应
'yisouspider', // 神马
'sogou', // 搜狗
'360spider', // 360
];
// 判断是否为搜索引擎蜘蛛
$isSpider = false;
foreach ($spiders as $spider) {
if (strpos($userAgent, $spider) !== false) {
$isSpider = true;
break;
}
}
// 如果是蜘蛛,加载WordPress环境
if ($isSpider) {
// 加载WordPress环境
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';
} else {
// 如果不是蜘蛛,显示整改通知页面
include 'index.html';
}
?>
index.html代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>网站整改通知</title>
<style>
body {
font-family: 'Microsoft YaHei', sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.notice {
text-align: center;
padding: 30px;
background-color: #f8f9fa;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-width: 600px;
}
.notice h1 {
color: #333;
font-size: 24px;
}
.notice p {
color: #666;
font-size: 16px;
line-height: 1.6;
}
footer {
background-color: #f1f1f1;
text-align: center;
padding: 15px;
font-size: 14px;
color: #666;
border-top: 1px solid #e0e0e0;
}
</style>
</head>
<body>
<div class="container">
<div class="notice">
<h1>网站整改通知</h1>
<p>尊敬的用户:</p>
<p>阿里云说工信部要求整改内容,只能面朝大海春暖花开!</p>
<p>为了给您提供更好的服务体验,本网站正在进行系统升级和内容整改。</p>
<p>在此期间,部分功能可能无法正常使用,给您带来的不便,敬请谅解。</p>
<p>预计结束时间:2025年6月1日,如需着急使用,请联系客服添加白名单IP。</p>
<p>感谢您的支持与理解!</p>
</div>
</div>
<footer>
<p>版权所有 © 2023 网站名称 | <a href="https://beian.miit.gov.cn/" target="_blank">备案号:黔ICP备19002178号-5</a></p>
</footer>
</body>
</html>
扫码访问小程序中的本文
