Nginx Exclude Certain bots

NGINX exclude certain bots like the Internet Archiver Bot

There are enough examples on the internet to exclude certain bots via .htaccess.

There aren’t so many examples for when using Nginx.

That is why I wrote this article. It is based on this excellent guide to exclude all bots via Builder Society.

Exclude Internet Archiver Bot

Insert this part somewhere within the http section of your nginx config file:

map $http_user_agent $limit_bots {
         default 0;
         ~*(archive.org_bot|archive|ia_archiver) 1;

And then:

Include this within your server => location tag. For example when using Laravel with Nginx:

server {

    if ($limit_bots = 1) {
        return 301;

Always check if your site still works properly.

You can test the bot simulator by entering your URL and the bot name: archive.org_bot on this bot simulator.

It should return something like:

HTTP/2 301
server: nginx
content-type: text/html

Use on your own risk. Happy coding!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top