robots.txt htaccess block google

和自甴很熟 提交于 2020-01-14 12:39:09

问题


In my .htaccess file I have:

<Files ~ "\.(tpl|txt)$">
Order deny,allow
Deny from all
</Files>

This denies any text file from being read, but the Google search engine gives me the following error:

robots.txt Status

http://mysite/robots.txt

18 minutes ago  302 (Moved temporarily)

How can I modify .htaccess to permit Google to read robots.txt while prohibiting everyone else from accessing text files?


回答1:


Use this:

<Files ~ "\.(tpl|txt)$">
  Order deny,allow
  Deny from all
  SetEnvIfNoCase User-Agent "Googlebot" goodbot
  Allow from env=goodbot
</Files>


来源:https://stackoverflow.com/questions/7475870/robots-txt-htaccess-block-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!