在 robots.txt 中,仅允许抓取共享主机上的子域而不是子目录?

发布于 2025-01-07 06:57:10 字数 301 浏览 4 评论 0原文

我刚刚更改了 DNS 设置,因此文件夹 /forum 现在是子域而不是子目录。如果我创建一个 robots.txt 文件并说:

User-agent: *
Disallow: /forum

这会禁止对子目录和子域进行爬网吗?

我想禁止爬行子目录,但允许爬行子域。 注意:这是在共享主机上,因此子目录和子域都可以访问。这就是我有这个问题的原因。

那么,如何只允许对子域进行抓取?

I just changed the DNS settings so the folder /forum is now a subdomain instead of a subdirectory. If I do a robots.txt file and say:

User-agent: *
Disallow: /forum

Will that disallow crawling for the subdirectory AND subdomain?

I want to disallow crawling of the subdirectory, but ALLOW crawling of the subdomain. Note: this is on shared hosting so both the subdirectory and subdomain can be visited. This is why I have this issue.

So, How can I only permit crawling for the subdomain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自在安然 2025-01-14 06:57:10

如果你想停止爬行,这是正确的方法。但请注意:如果 URL 已被索引,则不会被删除。

我更喜欢的方法是通过元标记将所有页面设置为“noindex/follow”,或者更好的是“规范标记”将搜索引擎流量发送到子域网址
进入您的

在给定的 URL(例如“http://www.yourdomain.com/directoryname/post-of-the-day”)上使用

<link rel="canonical" href="http://directoyname.yourdomain.com/post-of-the-day" />

最新的 URL 将是 SERP 中唯一的 URL

It's the correct way, if you want to stop crawling. But note: If the URLs are already indexed, the won't be removed.

The way I would prefer is to set all pages to "noindex/follow" via meta tags or even better you the "canonical tag" to send the search engines traffic to the subdomain url
Into your

On a given URL like "http://www.yourdomain.com/directoryname/post-of-the-day" use

<link rel="canonical" href="http://directoyname.yourdomain.com/post-of-the-day" />

The latest URL will be the only one in SERPs

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文