大网数据广告活动
网站运营与故障问答

How to block Googlebot from accessing one specific page

· 52CE 我爱测

I am getting spammed by this IP: 66.249.79.70 , and this website is telling me that it is from Google: https://ipinfo.io/66.249.79.70 It is filling one of my input boxes and keeps posting. I want to block this bot (with IP addres…

问题原文

原帖链接 · arunwebber · CC BY-SA 3.0

I am getting spammed by this IP: 66.249.79.70, and this website is telling me that it is from Google: https://ipinfo.io/66.249.79.70

It is filling one of my input boxes and keeps posting. I want to block this bot (with IP address: 66.249.79.xxx) from accessing one specific page (e.g., www.example.com/blocked.php) using an .htaccess file, how can I do that? I don't want to block the IP address completely though because I don't doubt it's from Google.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

Since this does appear to be the real Googlebot, the recommended way to block access/crawling is to use /robots.txt:

User-agent: googlebot
Disallow: /blocked.php

However, if you still want to block this IP using .htaccess then you can do something like the following, near the top of your root .htaccess file:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} =66.249.79.70
RewriteRule ^blocked\.php - [F]

This will return a "403 Forbidden" when a user with the above IP address attempts to access /blocked.php. Note that the "user/bot" still tries to access the URL by making a request, whereas with robots.txt they shouldn't even make the request (assuming they obey the robots.txt "standard"; which Googlebot does).

However, bear in mind that Googlebot can crawl from different IP addresses, so this may need to be updated in the future.


If you did want to block the range of IP addresses denoted by 66.249.79.xxx, then you could change the above condition to:

RewriteCond %{REMOTE_ADDR} ^66\.249\.79\.

However, that could block more than just Googlebot and may not be any more successful at blocking Googlebot than checking the specific IP address above (Googlebot does not necessarily crawl on a continuous IP block).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。