How to Block AhrefsBot (robots.txt and .htaccess rules)

This guide explains how to block AhrefsBot from crawling a website.

Below, you’ll find three methods for blocking AhrefsBot using the robots.txt file, .htaccess rules, and Cloudflare firewall. Either of these options will prevent AhrefsBot from accessing a website to crawl its link data and make it unavailable to Ahrefs users who are trying to analyze the domain for search engine optimization (SEO) and digital marketing campaigns.

If you want to learn more about what AhrefsBot is and how it works, then see this related page on AhrefsBot.

How to Block AhrefsBot

How to Block AhrefsBot

1. Use the robots.txt Blocking Rule

AhrefsBot can be blocked from visiting your website by adding the following rule to the robots.txt file:

User-agent: AhrefsBot
Disallow: /

AhrefsBot always respects the Disallow directive that instructs the spider not to crawl the website and will block AhrefsBot from storing link data about the site in its database. However, AhrefsBot does need time to pick up the Disallow directive if this is a newly added change in your robots.txt file. Once discovered, AhfefsBot will honor the Disallow directive during the next scheduled crawl.

Note: SemrushBot can also be blocked using the Disallow directive in the robots.txt file. See this related guide on how to block SemrushBot if you want to prevent that bot from crawling your website.

2. Use the .htaccess Blocking Rule

AhrefsBot can be blocked by using an IP deny rule in the website’s root .htaccess file. AhrefsBot uses both individual IP addresses and IP ranges, so you’ll need to deny all of them to prevent the bot from crawling the website.

Order Allow,Deny
Deny from 54.36.148.0/24
Deny from 54.36.149.0/24
Deny from 195.154.122.0/24
Deny from 195.154.123.0/24
Deny from 195.154.126.0/24
Deny from 195.154.127.0/24
Deny from 51.222.253.0/26
Deny from 168.119.64.245
Deny from 168.119.64.246
Deny from 168.119.64.247
Deny from 168.119.64.248
Deny from 168.119.64.249
Deny from 168.119.64.250
Deny from 168.119.64.251
Deny from 168.119.64.252
Deny from 168.119.64.253
Deny from 168.119.64.254
Deny from 168.119.65.107
Deny from 168.119.65.108
Deny from 168.119.65.109
Deny from 168.119.65.110
Deny from 168.119.65.111
Deny from 168.119.65.112
Deny from 168.119.65.113
Deny from 168.119.65.114
Deny from 168.119.65.115
Deny from 168.119.65.116
Deny from 168.119.65.117
Deny from 168.119.65.118
Deny from 168.119.65.119
Deny from 168.119.65.120
Deny from 168.119.65.121
Deny from 168.119.65.122
Deny from 168.119.65.123
Deny from 168.119.65.124
Deny from 168.119.65.125
Deny from 168.119.65.126
Deny from 168.119.65.43
Deny from 168.119.65.44
Deny from 168.119.65.45
Deny from 168.119.65.46
Deny from 168.119.65.47
Deny from 168.119.65.48
Deny from 168.119.65.49
Deny from 168.119.65.50
Deny from 168.119.65.51
Deny from 168.119.65.52
Deny from 168.119.65.53
Deny from 168.119.65.54
Deny from 168.119.65.55
Deny from 168.119.65.56
Deny from 168.119.65.57
Deny from 168.119.65.58
Deny from 168.119.65.59
Deny from 168.119.65.60
Deny from 168.119.65.61
Deny from 168.119.65.62
Deny from 168.119.68.117
Deny from 168.119.68.118
Deny from 168.119.68.119
Deny from 168.119.68.120
Deny from 168.119.68.121
Deny from 168.119.68.122
Deny from 168.119.68.123
Deny from 168.119.68.124
Deny from 168.119.68.125
Deny from 168.119.68.126
Deny from 168.119.68.171
Deny from 168.119.68.172
Deny from 168.119.68.173
Deny from 168.119.68.174
Deny from 168.119.68.175
Deny from 168.119.68.176
Deny from 168.119.68.177
Deny from 168.119.68.178
Deny from 168.119.68.179
Deny from 168.119.68.180
Deny from 168.119.68.181
Deny from 168.119.68.182
Deny from 168.119.68.183
Deny from 168.119.68.184
Deny from 168.119.68.185
Deny from 168.119.68.186
Deny from 168.119.68.187
Deny from 168.119.68.188
Deny from 168.119.68.189
Deny from 168.119.68.190
Deny from 168.119.68.235
Deny from 168.119.68.236
Deny from 168.119.68.237
Deny from 168.119.68.238
Deny from 168.119.68.239
Deny from 168.119.68.240
Deny from 168.119.68.241
Deny from 168.119.68.242
Deny from 168.119.68.243
Deny from 168.119.68.244
Deny from 168.119.68.245
Deny from 168.119.68.246
Deny from 168.119.68.247
Deny from 168.119.68.248
Deny from 168.119.68.249
Deny from 168.119.68.250
Deny from 168.119.68.251
Deny from 168.119.68.252
Deny from 168.119.68.253
Deny from Deny from 168.119.68.254
Allow from all

3. Block with Cloudflare

If you’re using Cloudflare, you can add the individual IP addresses below to the firewall block list to prevent AhrefsBot from crawling the website.

51.222.253.0
51.222.253.1
51.222.253.2
51.222.253.3
51.222.253.4
51.222.253.5
51.222.253.6
51.222.253.7
51.222.253.8
51.222.253.9
51.222.253.10
51.222.253.11
51.222.253.12
51.222.253.13
51.222.253.14
51.222.253.15
51.222.253.16
51.222.253.17
51.222.253.18
51.222.253.19
51.222.253.20
51.222.253.21
51.222.253.22
51.222.253.23
51.222.253.24
51.222.253.25
51.222.253.26
51.222.253.27
51.222.253.28
51.222.253.29
51.222.253.30
51.222.253.31
51.222.253.32
51.222.253.33
51.222.253.34
51.222.253.35
51.222.253.36
51.222.253.37
51.222.253.38
51.222.253.39
51.222.253.40
51.222.253.41
51.222.253.42
51.222.253.43
51.222.253.44
51.222.253.45
51.222.253.46
51.222.253.47
51.222.253.48
51.222.253.49
51.222.253.50
51.222.253.51
51.222.253.52
51.222.253.53
51.222.253.54
51.222.253.55
51.222.253.56
51.222.253.57
51.222.253.58
51.222.253.59
51.222.253.60
51.222.253.61
51.222.253.62
51.222.253.63

Blocking Google Analytics and Search Console

If you’re a current Ahrefs user and you’ve connected your Google Analytics or Search Console properties to your Ahrefs account, then you’ll also need to disconnect those websites. Otherwise, Ahrefs can still access your private website data for reporting purposes.

Block AhrefsBot Summary

I hope you enjoyed this guide on how to block AhrefsBot.

As you discovered, there are three ways to block AhrefsBot from crawling a website: using the .robots.txt file, .htaccess rules, and Cloudflare firewall. Either of these options will prevent AhrefsBot from accessing a website to crawl its link data and make it unavailable to Ahrefs users who are trying to analyze the domain for digital marketing and SEO campaigns.