【问题标题】:Restrict indexing and remove current indexes限制索引并删除当前索引
【发布时间】:2016-03-29 19:37:21
【问题描述】:

我已经查看了有关此主题的几个问题,但我仍然不确定我是否正确。

我有一个 php 文件,它根据 GET 参数返回 xml/json 响应。

http://someDomain.com/get.php?param=option1

Google 已经将其中的一些网址编入索引。

据我了解,我可以通过添加 someDomain.com/robots.txt 来限制机器人索引 someDomain.com 上的任何其他网址:

User-agent: *
Disallow: *

我了解通过添加 robots.txt 搜索引擎将无法看到 noindex 元数据以删除当前的索引网址。

但是 get.php 并没有返回任何元/头信息,因为它只返回 json/xml 数据。

那么我怎样才能让谷歌从搜索结果中删除已经编入索引的网址呢?

【问题讨论】:

  • 对 google bot 使用 301 重定向
  • @Starkeen 你的意思是像:Redirect 301 /get.php /blackwhole/ 吗?我怎样才能只重定向谷歌机器人而不是其他任何东西?

标签: .htaccess search indexing robots.txt


【解决方案1】:

在 htaccess 中尝试以下代码:

RewriteEngine On

#If user agent is "googlebot"
RewriteCond %{HTTP_USER_AGENT} googlebot [NC]
#And query string is "param=anychar"
RewriteCond %{QUERY_STRING} ^param=(.+)$ [NC]
#Then 301 redirect "get.php" to "/backwhole"
RewriteRule ^get\.php$ /backwhole [L,R=301]

【讨论】:

  • 感谢您的回答。只是一个快速的子问题:我会在 /blackhole 文件夹中放入什么? index.php 文件输出forbidden 标头?我怎样才能让这个 htaccess 文件返回 forbidden 或一些类似的标头,而不是为此重定向和创建文件夹?有可能吗?
  • 请您澄清一下?那个“黑洞”只是一个例子。它仍然没有完全回答我的问题。
猜你喜欢
  • 2014-10-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多