grigione
grigione

Reputation: 717

robots.txt htaccess block google

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?

Upvotes: 4

Views: 3059

Answers (1)

Book Of Zeus
Book Of Zeus

Reputation: 49877

Use this:

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

Upvotes: 7

Related Questions