php - 如何在具有多个域的godaddy共享服务器中创建robot.txt

标签 php html robots.txt googlebot

下午好,希望您能帮助我,我有一个问题:

我有一个 godaddy 的服务器(豪华共享),在这个服务器上我有以下内容:

/
--/邮件
--/等等
--/public_html
----/web1
----/web2
------/index.php
------/css
------/img
------/js
----/web3
--/tmp

我正在创建一个robot.txt文件,我不想在其中对web2中的任何内容进行索引,所以对我来说什么都没有(index.html,css,img,js),但是想要索引其他页面(web1, web3) 我怎样才能做到这一点?该文件夹中的robot.txt 文件必须去吗?在/、/public_html、/web2 中?

我可以帮忙处理文件内容:robot.txt?

提前非常感谢您。

最佳答案

您将使用两个不同的 robots.txt 文件。一个进入/web1,另一个进入/web2。就爬网程序而言,如果/web1 是“somedomain.com”的根目录,它们将无法爬行文件夹并爬到/web2 文件夹(或同一级别的任何其他文件夹)。

编辑:一些示例 robots.txt 文件

从整个服务器中排除所有机器人(其中“服务器”==“域”)

User-agent: *
Disallow: /

允许所有机器人完全访问

User-agent: *
Disallow:

(或者只是创建一个空的“/robots.txt”文件,或者根本不使用)

从服务器的一部分中排除所有机器人

User-agent: *
Disallow: /cgi-bin/
Disallow: /tmp/
Disallow: /junk/

排除单个机器人

User-agent: BadBot
Disallow: /

允许单个机器人

User-agent: Google
Disallow:

User-agent: *
Disallow: /

因此,/web2 将获得一个 robots.txt 文件,其中包含:

User-agent: *
Disallow: /

/web1/web3将得到空的robot.txt文件或

User-agent: *
Disallow:

关于php - 如何在具有多个域的godaddy共享服务器中创建robot.txt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23821925/

相关文章:

图像重叠背景的 HTML 表

ruby-on-rails-4 - 在 robots.txt 中阻止 ?page=

php - mysql查询左连接的两个表-得到错误的结果

PHP include 在短标签中运行,即使短标签已关闭

python - 在 python 中创建 HTML

sitemap - 如何为 robots.txt 中的特定爬虫机器人分配特定站点地图?

seo - 使用 robots.txt 阻止来自搜索引擎的 100 多个 url

php - MySQL查询从两个表中获取数据

PHP 时间戳 -> strtotime -> 时间戳

javascript - 黑莓网络上的 Canvas Action 太慢