php - 谷歌的 Robots.txt 错误

标签 php html apache web seo

我在添加 sitemap.xml 时在我的 Google 网站站长工具中遇到了这个错误

URL restricted by robots.txt

在我的 robots.txt 中我有:

User-agent: *
Allow: /$
Disallow: /

它只是为了索引我的主页而不是所有网站。

最佳答案

为什么那里有 $。为什么 Disallow:/:

User-agent: *
Allow: /$
Disallow: /

只需将其更改为:

User-agent: *
Allow: /

但是如果你只想让它索引实际的索引页,那么就把它改成这样:

User-agent: *
Allow: /index.php
Disallow: /

或者也许这样做会改变指令的顺序:

User-agent: *
Disallow: /
Allow: /index.php
Allow: /$

最后一个示例结合了您的 robots.txt 项目,但也对它们进行了重新排序。所以它应该像你想要的那样工作;只有索引页,没有别的。

关于php - 谷歌的 Robots.txt 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23945655/

相关文章:

php - 清理所有已发布字段的正确方法?

php - 如何使用 CodeIgniter 测试 Controller ?

javascript - Ajax请求仅返回错误但状态码为200 OK

html - 位于 materialize.css 复选框下方的多个选择选项文本

css - .htaccess mod_rewrite 将所有 css 重定向到页面/ Controller

php - 无法向 IMAP 服务器进行身份验证 : [AUTHENTICATIONFAILED] Invalid credentials (Failure)

javascript - 在页面顶部显示您的应用程序

html - 如何在 Swift 中动态加载 HTML

Apache 多个站点,一个有效,另一个无效

php 脚本获取 'exec format error' 或 'permission error'