如何防止漫游器在CodeIgniter中创建会话? [英] How to prevent bots from creating sessions in CodeIgniter?

查看:61
本文介绍了如何防止漫游器在CodeIgniter中创建会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对存储在数据库中的会话使用CodeIgniter。
在短时间内,僵尸程序/蜘蛛等会创建大量会话。

I am using CodeIgniter with sessions stored in my database. Over a short period of time, a large amount of sessions are created by bots/spiders, etc.

是否可以防止这种情况发生?也许通过.htaccess吗?

Is there a way of preventing this? Perhaps via .htaccess?

推荐答案

首先,您应该在域的Web根目录中创建robots.txt文件以进行寻址两个问题。首先要控制网站的爬网速度,这可以防止机器人/蜘蛛同时创建大量数据库连接。其次,防止特定的漫游器爬网该网站。使用以下默认值,但是您可能想要添加或删除被拒绝的用户代理,并调整爬网速度

First and foremost you should create a robots.txt file in the web root of the domain to address two issues. First to control the rate at which the website is being crawled which can help prevent a bot/spider from creating a massive number of database connections at the same time. Second to prevent specific bots from crawling the website. use the following defaults, however you might want to add or remove the user agents denied, and adjust the crawl rate

示例代码:

User-agent: *
Crawl-delay: 10

User-agent: Baiduspider
Disallow: /

User-agent: Sosospider
Disallow: /

有使用/robots.txt时有两个重要注意事项:

There are two important considerations when using /robots.txt:


  1. 机器人可以忽略您的/robots.txt。尤其是扫描网络中的安全漏洞的恶意软件机器人,以及垃圾邮件发送者使用的电子邮件地址收集器,都不会引起注意。

  2. /robots.txt文件是公开可用的文件。任何人都可以看到您不希望机器人使用服务器的哪些部分。

这篇关于如何防止漫游器在CodeIgniter中创建会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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