访问使用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]
等。