【发布时间】:2020-07-23 20:55:12
【问题描述】:
我正在尝试设置 X-Robots-Tag 以允许 Googlebot 为我的网站编制索引。我没有robots.txt 文件,并且在我的任何html 文件中都没有与X-Robots-Tag 相关的任何元标记。 Apache 服务器正在返回一个标头,其中 X-Robots-Tag 设置为 "noindex, nofollow"。如何通过编辑.htaccess 文件取消设置此标签?
这是我在使用 Chrome 插件“机器人排除检查器”时得到的:
X-Robots status BLOCKED noindex,nofollow.
Date: Thu, 23 Jul 2020 20:27:46 GMT
Content-Type: text/html
Content-Length: 1272
Connection: keep-alive
Keep-Alive: timeout=30
Server: Apache/2
X-Robots-Tag: noindex, nofollow
Last-Modified: Fri, 09 Mar 2018 19:26:43 GMT
ETag: "ae0-xxxxxxxxxx-gzip"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Cache-Control: max-age=3600
Expires: Thu, 23 Jul 2020 21:27:46 GMT
我的.htaccess 文件的内容:
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>
Header onsuccess unset X-Robots-Tag
Header always set X-Robots-Tag "index,follow"
我已尝试将其添加到 .htaccess 文件的底部:
<files *.html>
Header set X-Robots-Tag "index,follow"
</files>
然后我从 Chrome 扩展程序中得到这个响应:
X-Robots BLOCKED noindex,nofollow,index,follow.
(注意它在下面的列表中出现了两次。)
Date: Thu, 23 Jul 2020 20:39:42 GMT
Content-Type: text/html
Content-Length: 1272
Connection: keep-alive
Keep-Alive: timeout=30
Server: Apache/2
X-Robots-Tag: noindex, nofollow
Last-Modified: Fri, 09 Mar 2018 19:26:43 GMT
ETag: "ae0-xxxxxxxxxxxxx-gzip"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Cache-Control: max-age=3600
Expires: Thu, 23 Jul 2020 21:39:42 GMT
X-Robots-Tag: index,follow
有没有办法删除原来的X-Robots-tag 标头并用新标头替换?我试过Header unset X-Robots-Tag,但不行(仍然显示“BLOCKED noindex,nofollow”)。
解决方案:对我有用的是包含 robots.txt 文件并确保所有超链接都以斜杠结尾。似乎没有斜杠,我得到一个 301 重定向,其中包括有问题的 noindex,nofollow 标头。
【问题讨论】:
-
"如何通过编辑 .htaccess 文件取消设置此标签?" - 你真的不需要 - 你需要首先找到这个标题的设置位置。 “Apache 服务器正在返回一个标头” - 是的,但很可能是您的应用程序设置此标头。
-
我的 index.html 页面非常非常简单,只有正文内的超链接指向网站的其他部分。
主页 ... -
您的服务器配置中有什么?
X-Robots-Tag不会自行设置 - 它必须在配置中的某处显式设置。你有什么样的主机? -
@MrWhite 该网站托管在 freeyellow 上。这是服务器信息的链接:mwganson.freeyellow.com/cgi-bin/server_information.php,但我没有看到与 x-robots-tag 相关的任何内容。我在所有文件中搜索了“robots”、“noindex”和“nofollow”,但一无所获。