Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a directory full of images, that I do not want viewed by robots, is there a way to make this directory private?

Thanks!

share|improve this question
    
Just as a warning, robots.txt does not keep all robots out, but at least it won't be indexed by Google. –  akway Jul 22 '09 at 15:48
add comment

migrated from stackoverflow.com Jul 22 '09 at 16:27

This question came from our site for professional and enthusiast programmers.

7 Answers

up vote 10 down vote accepted

How to Use Robots.txt in Search Engine Optimization ( SEO )

Type-in " Disallow: /folder name "
for any folder containing files you don’t want search engines to crawl.

Or, type-in " Disallow: /filename.filetype "
for any page or file you don’t want search engines to index.

Note of the following example :

* Disallow: /private/
* Disallow: /private/image01.jpg
share|improve this answer
1  
Nice answer. Referenced external site with more information. Provided summary from the site. Added example. –  tvanfosson Jul 22 '09 at 15:45
1  
Thank you for the great description! –  Frederico Jul 22 '09 at 15:49
add comment

You want robots.txt

share|improve this answer
add comment

Yeah like this:

User-agent: *
Disallow: /MyImageDirectory
share|improve this answer
add comment

Create a robots.txt file in your site's root directory. Inside that file put

User-agent: *
Disallow: /images
share|improve this answer
add comment

It's called a robots.txt file, and most all robots will honor your requests in your robots.txt.

You'll want something like the following:

User-Agent: *
Disallow: /path/to/images/
share|improve this answer
add comment

In your root directory you can place a robots.txt file that forbids robots to index specific directories.

share|improve this answer
add comment

robots.txt is only obeyed by well-behaved robots. not all of them are well-behaved like those of the major search engines - some are written by incompetent buffoons, some are written by spammers trawling for email addresses, and so on.

anyway, you also want to turn Indexes off for that directory...either with a .htaccess file or in your apache conf like so:

<Directory /path/to/images/dir>
  Options -Indexes
</Directory >

or by by placing a blank index.html file in there.


this will stop them from seeing a directory listing of the image files. it won't stop them from following direct links to the images from other pages on your site.

there's actually very little you can do to really prevent robots from accessing public files on your webserver that won't either inconvenience your users or increase the load on your server by only serving images through a script that only serves to logged-in users (e.g. by checking a cookie).

share|improve this answer
add comment

protected by Tom O'Connor Sep 17 '13 at 10:07

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.