# How to block PetalBot with Cloudflare

URL: https://wp24x7.com/how-to-block-petalbot-using-cloudflare/
Updated: 2026-11-29
Type: blog post
Audience: WordPress site owners and admins using Cloudflare

> PetalBot is the crawler behind Petal Search, and on a small WordPress server a heavy crawl can look like a traffic spike. To block it, create a Cloudflare custom rule where the user agent contains PetalBot and set the action to Block, or add a Disallow line to robots.txt first. A rate limit is a gentler option. Test with curl and check Security Events.

## Key facts

- For: owners whose server is slowed by PetalBot crawling
- Options: robots.txt, Cloudflare custom rule, rate limiting
- Rule: (http.user_agent contains "PetalBot") or (http.user_agent contains "PetalSearch")
- Effect on Google: none; Google uses Googlebot
- Safety: note current rules first; start with Managed Challenge if cautious
- Test: curl with a spoofed user agent should return 403
- Help: speed optimization and WordPress support

PetalBot is the crawler behind Petal Search. On a small WordPress server, a heavy crawl can look like a traffic spike. **To block it, create a Cloudflare custom rule where the user agent contains "PetalBot" and set the action to Block. If you would rather ask nicely first, add a Disallow line to robots.txt.**

> **Quick answer**
Back up your site and note your current Cloudflare rules before you change anything: a wrong expression can lock out real visitors. Consider Managed Challenge before Block.

## How do I know PetalBot is the problem?

Do not block on a hunch. Check first:

- Look at raw access logs (your host's panel, or `/var/log/nginx/access.log` on a VPS) and search for `PetalBot`. A few hundred requests a day is normal; tens of thousands from one crawler is worth acting on.
- In Cloudflare, open **Analytics & Logs** and filter by user agent if your plan shows it.
- Check whether load lines up with PHP workers at their limit or high CPU. Crawlers requesting many uncached URLs, such as search results and filters, cost far more than ones fetching static pages.

## Which option should I choose?

| Option | Strength | Limit |
|---|---|---|
| robots.txt | Gentle, honest crawlers obey it | Not instant; bad bots ignore it |
| Cloudflare custom rule | Stops requests at the edge | A wrong expression can block real visitors |
| Rate limiting | Lets Petal Search index you without hammering | Needs tuning |

_Stopping a crawler at the edge, before it reaches the server_

## How do I apply each option?

### Cloudflare rule
Cloudflare's WAF custom rules replaced the older Firewall Rules screen.

1. Log in to Cloudflare and choose your domain.
2. Go to **Security, WAF, Custom rules** and click **Create rule**.
3. Name it, for example `Block PetalBot`.
4. Under **When incoming requests match**, click **Edit expression** and paste:

```
(http.user_agent contains "PetalBot") or (http.user_agent contains "PetalSearch")
```

5. Set **Then take action** to **Block** and deploy.

Matching on `contains` is case-sensitive in Cloudflare expressions, so use `lower(http.user_agent) contains "petalbot"` to catch variations. For caution, set the action to **Managed Challenge** first.
### robots.txt
PetalBot documents that it respects robots.txt. Add this to the file at your site root:

```
User-agent: PetalBot
Disallow: /
```

To slow it instead of banning it, disallow only expensive paths:

```
User-agent: PetalBot
Disallow: /?s=
Disallow: /wp-admin/
Disallow: /*?orderby=
```

Changes are picked up the next time it fetches robots.txt.
### Rate limit
If you want Petal Search to index you but not hammer you, add a rate limiting rule that matches the same user-agent expression and allows a modest number of requests per minute from each IP. Cloudflare shows the limits for your plan on the rate limiting page. Set the action to Block for the rest of the window and keep the threshold generous at first.

## How do I check the rule works?

Use your own terminal and fake the user agent:

```
curl -I -A "Mozilla/5.0 (compatible; PetalBot;+https://webmaster.petalsearch.com/site/petalbot)" https://example.com/
```

Replace `example.com` with your domain. A blocked request returns **403** with a Cloudflare error page, and a normal request should still return 200. Then watch **Security, Events** in Cloudflare, which lists each blocked request with the rule that matched.

## What can go wrong?

| Problem | Why | Fix |
|---|---|---|
| Blocking too broadly | A short string like `bot` catches Googlebot and Bingbot | Match `PetalBot` only |
| Rule order | An earlier "allow" rule stops yours running | Move the block above it |
| Origin still exposed | Bots reaching your server IP skip Cloudflare | Restrict the origin to Cloudflare's published ranges |
| Spoofed agents | A user-agent string is just text | Treat the rule as a filter for honest crawlers, not security |

## When should I leave PetalBot alone?

If you sell to people who use Huawei devices or Petal Search, a crawl is how you appear there, so slow it down rather than banning it. Keep a short record of what you decided and why, and review custom rules every few months: Security Events shows how often each rule fires, and a rule that has not matched for months can go.

## What else reduces crawler load?

Bots do the most damage on pages WordPress must build from scratch every time. Page caching, a CDN rule that caches static files and blocking internal search results from crawling remove most of the cost, whoever is crawling. For a server that buckles under routine crawler traffic, see [WordPress speed optimization](/wordpress-speed-optimization) or an ongoing [WordPress support](/wordpress-support) plan. For other protections, read our guide to [Cloudflare rules that secure WordPress](/5-simple-rules-in-cloudflare-to-secure-your-wordpress-website).

**Spike taking your site down?**
An engineer can read the logs with you.
[Post a project](/post-project)
[Emergency WordPress support](/wordpress-emergency-support)

## Frequently asked questions

### Is PetalBot a malicious bot?

No. It is the crawler of Huawei's Petal Search, a real search engine. It becomes a problem only when it sends enough requests to slow a small server, which is why many site owners limit or block it.

### Will blocking PetalBot hurt my Google rankings?

No. Google uses Googlebot, not PetalBot. You lose only visibility in Petal Search, which matters mostly if your audience uses Huawei devices.

### Can a bot ignore the block by faking its user agent?

Yes. A user-agent rule stops honest crawlers. Aggressive scrapers can claim to be a browser, so pair the rule with rate limiting or Cloudflare's bot controls if you see abuse.

### How do I know PetalBot is the problem?

Search your raw access logs for PetalBot. A few hundred requests a day is normal; tens of thousands from one crawler is worth acting on, especially if load lines up with PHP workers at their limit or high CPU.

### Does PetalBot respect robots.txt?

PetalBot documents that it does. Add a User-agent: PetalBot group with Disallow: / to ban it, or disallow only expensive paths. Changes apply the next time it fetches robots.txt, so it is not instant.

### Where do I add a Cloudflare custom rule?

Under Security, WAF, Custom rules, choose Create rule, name it, edit the expression and set the action to Block. Cloudflare's custom rules replaced the older Firewall Rules screen.

### Should I use Block or Managed Challenge?

Managed Challenge is the cautious first step. Real crawlers cannot solve it so it works almost like a block, and a mistake costs a real visitor one click instead of a blocked page.

### How can I check the rule works?

Run curl -I with the PetalBot user agent against your domain. A blocked request returns 403 with a Cloudflare error page, and a normal request still returns 200. Security Events lists each blocked request.

### Why did my block rule not run?

Cloudflare evaluates custom rules in order, so an earlier allow rule can stop yours running. Move the block above it. Also check that bots cannot reach your origin IP directly.

### What mistakes should I avoid?

Matching a short string like bot, which catches Googlebot and Bingbot and can remove your pages from search. Treating a user-agent string as security, since it is just text.

### Is there a gentler option than blocking?

Yes. A rate limiting rule that matches the same user agent allows Petal Search to index you without hammering the server. Keep the threshold generous at first.

### What else reduces crawler load?

Page caching, a CDN rule that caches static files and blocking internal search results from crawling remove most of the cost, whoever is crawling.
