我正在尝试设置X-Robots-Tag
为允许 Googlebot 为我的网站编制索引。我没有文件,也没有与我的任何 html 文件robots.txt
相关的任何元标记。X-Robots-Tag
Apache 服务器正在返回一个X-Robots-Tag
设置为的标头"noindex, nofollow"
。如何通过编辑.htaccess
文件取消设置此标签?
这是我在使用 Chrome 插件“机器人排除检查器”时得到的:
X-Robots 状态被封锁 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 标头。