0

I want to block all bots (like a HTTrack) on my website. Normally, I would use .htaccess file to block bots via RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR].

However, my server is running Node.js Express. How can I get HTTP_USER_AGENT and do a block or rewritecond on Node.js?

Andrew Myers
  • 2,754
  • 5
  • 32
  • 40

1 Answers1

0

There is a middleware for that, called express-nobots:

var noBots = require('express-nobots');

// must be the first middleware
app.use(noBots());

You can see the list of blocked bots inside a source file.

Shanoor
  • 13,344
  • 2
  • 29
  • 40
  • thank you i installed and it didnt work then i realise in bots.js they write HTTrack wrong i changed and BAM! it's work thanks i think we must send mail about this – Barış Saçıkara Apr 25 '16 at 18:07