访问使用htaccess的某个目录禁止某些机器人 [英] Disallow certain bots from accessing certain directory using htaccess

查看:145
本文介绍了访问使用htaccess的某个目录禁止某些机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的网站上访问某些目录阻止某些机器人。这几乎是相同的<一href="http://stackoverflow.com/questions/10735766/block-all-bots-crawlers-spiders-for-a-special-directory-with-htaccess">this问题只是我不想我要阻止的每个文件夹中创建不同的.htaccess文件。我需要使用根.htaccess文件。

I need to block certain bots from accessing certain directories on my website. This is almost identical to this question except that I don't want to create different .htaccess file in each folder I want to block. I need to use the root .htaccess file.

正则表达式已经让我很难真的。鸭preciate你的帮助

Regex has been giving me a hard time really. Appreciate your help

推荐答案

只需创建一个文件夹列表,每一个前添加相同的条件:

Just create a list of folders and add the same condition before each one:

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC]
RewriteRule ^folder1/ - [L,F]

RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC]
RewriteRule ^folder2/anotherfolder/ - [L,F]

RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC]
RewriteRule ^folder3/path/to/disallowedfolder/ - [L,F]

等。

这篇关于访问使用htaccess的某个目录禁止某些机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆