I'm trying to set X-Robots-Tag
to allow Googlebot to index my website. I don't have a robots.txt
file and I don't have any meta tags relating to X-Robots-Tag
in any of my html files. The Apache server is returning a header with X-Robots-Tag
set to "noindex, nofollow"
. How do I unset this tag by editing the .htaccess
file?
This is what I get when using the Chrome addon "Robots Exclusion Checker":
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
Contents of my .htaccess
file:
# 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"
I've tried adding this to the bottom of the .htaccess
file:
<files *.html>
Header set X-Robots-Tag "index,follow"
</files>
I then get this response from the Chrome extension:
X-Robots BLOCKED noindex,nofollow,index,follow.
(Notice it appears twice in the list below.)
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
Is there a way to delete the original X-Robots-tag
header and replace it with the new one? I tried Header unset X-Robots-Tag
, but no go (still shows "BLOCKED noindex,nofollow").
Solution: What has worked for me was to include a robots.txt file and to ensure all hyperlinks end with a trailing slash. It seems without the trailing slash I get a 301 redirect, which includes the offending noindex,nofollow header.