Block all bots/crawlers/spiders for a special directory with htaccess

后端 未结 3 435
一向
一向 2020-11-27 06:50

I\'m trying to block all bots/crawlers/spiders for a special directory. How can I do that with htaccess? I searched a little bit and found a solution by blockin

3条回答
  •  旧巷少年郎
    2020-11-27 07:22

    Why use .htaccess or mod_rewrite for a job that is specifically meant for robots.txt? Here is the robots.txt snippet you will need t block a specific set of directories.

    User-agent: *
    Disallow: /subdir1/
    Disallow: /subdir2/
    Disallow: /subdir3/
    

    This will block all search bots in directories /subdir1/, /subdir2/ and /subdir3/.

    For more explanation see here: http://www.robotstxt.org/orig.html

提交回复
热议问题