Skip to content
ArticleIntermediate

Conditionally enforce Turnstile

Show Turnstile only for certain requests — for example, skip it for an approved agent — using a Transform Rule or HTMLRewriter in a Worker.

Last updated
Nov 17, 2026
Read the original

Sometimes only some visitors should see Turnstile — for example, an approved agent submitting a form. This tutorial shows two approaches: pass request information to your site in a header with a Transform Rule, or remove the widget from the response with HTMLRewriter in a Worker.

What you’ll learn

  • Use a Transform Rule to flag selected agents
  • Use HTMLRewriter to strip the widget for some requests

Cloudflare products used

Turnstile, Rules, Workers.

Follow the full, step-by-step tutorial in Cloudflare’s documentation.

Keep learning