关于Discuz网站搜索引擎抓取问题,以下是系统性排查方案(无需联系他人,自主可操作):
一、核心配置文件检测
1. 检查`robots.txt`路径:`/robots.txt`
- 使用工具:Google Search Console的robots测试工具
- 关键排查点:确认未包含`Disallow: /forum.php`或过度限制目录
- 推荐设置(Apache示例):
- User-agent: *
- Allow: /forum.php
- Allow: /thread-*
- Disallow: /api/
- Disallow: /source/
复制代码
二、服务器级优化
2. 伪静态强化配置(Nginx增强版):
- rewrite ^/forum-(\w+)-([0-9]+)\.html$ /forum.php?mod=forumdisplay&fid=$2&page=$1 last;
- rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=viewthread&tid=$1&extra=page%3D$3&page=$2 last;
- add_header X-Robots-Tag "index, follow, max-snippet:-1, max-image-preview:large"; # 添加爬虫指令头
复制代码
三、数据提交通道
3. 实时推送接口部署:
- 在`source/module/forum/forum_index.php`中插入百度主动推送代码:
- // 在页面生成后追加
- $baidu_push_url = "http://data.zz.baidu.com/urls?site=您的域名&token=您的token";
- $urls = array($_G['siteurl']);
- $ch = curl_init();
- curl_setopt_array($ch, [
- CURLOPT_URL => $baidu_push_url,
- CURLOPT_POST => true,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POSTFIELDS => implode("\n", $urls),
- CURLOPT_HTTPHEADER => ['Content-Type: text/plain']
- ]);
- $result = curl_exec($ch);
- curl_close($ch);
复制代码
四、技术性屏蔽解除
4. 检查`/template/common/header_common.htm`:
- 移除`<meta name="robots" content="noindex,nofollow" />`标签
- 添加增强型meta:
- <meta name="googlebot" content="index,follow,snippet,archive" />
- <meta name="bingbot" content="index,follow,archive" />
复制代码
五、日志深度分析
5. 使用GoAccess分析日志(示例命令):
- grep -E 'Googlebot|Bingbot' access.log | goaccess --log-format=COMBINED -a -o report.html
复制代码
重点监测字段:
- HTTP状态码分布(重点关注4xx/5xx)
- 抓取频次波动
- 热门抓取路径TOP20
六、结构性优化
6. 在`/data/cache`目录创建搜索引擎专用缓存:
- // 修改source/class/discuz/discuz_application.php
- if(preg_match('/Googlebot|Bingbot/i', $_SERVER['HTTP_USER_AGENT'])) {
- $this->var['cachetype'] = 'searchengine'; // 单独缓存策略
- }
复制代码
七、实战检测工具
7. 使用curl模拟抓取测试:
- curl -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -I 您的帖子URL
复制代码
验证返回头中:
- HTTP/2 200
- 无X-Robots-Tag限制头
- 正确的内容类型(text/html)
建议依次执行上述步骤,每个环节操作后使用Google Search Console的"URL检查"工具进行即时验证。若在某个环节发现异常(如伪静态配置错误导致HTTP 500),可通过DZ-X.NET的技术文档库获取对应解决方案。完成全部优化后,通常需2-4周观察收录变化,期间保持内容日更(建议每日10+原创帖)。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。 |