AI agents & screen readers: for a machine-readable, text-only catalogue, start at /llms.txt. Products are available as Markdown (/products.md, /products/{handle}.md) and JSON (/products.json, /products/{handle}.json).
Store

Regular expressions in filtering

DNS Management

Regular expressions (regex) provide a powerful pattern-matching tool within Pi-hole, enabling sophisticated domain filtering that goes beyond simple exact matches. Where standard blocklist entries match specific domains, regex rules can match multiple domains based on patterns.

Consider these common Pi-hole regex patterns:

^ads\..*         # Blocks all domains starting with "ads."
.*\.example\.com # Blocks all subdomains of example.com
^(.+[-_.])??ads[.-].*$ # More comprehensive ad domain blocking

Managing Regex in Pi-hole:

  1. Through the web interface:
    • Navigate to "Blacklist" under "Group Management"
    • Select "Add regex filter" option
    • Enter your pattern
    • Save changes

Common Use Cases:

  • Block all subdomains of a problematic domain
  • Match common advertising domain patterns
  • Filter domains containing specific keywords
  • Block patterns that rotate domains (e.g., ad1.site.com, ad2.site.com)

A Word of Caution: Regex filters are powerful but require careful testing. An overly broad pattern might accidentally block legitimate domains. Always verify regex rules in the Query Log before implementing permanently.

Best Practice: Start with simple patterns and test thoroughly. Document your regex rules with comments explaining their purpose, as patterns can be difficult to decipher later.

Something here not working for you? Ask in the community — other makers and the Little Bird team read it.

Search The Pi-Hole Book

Type a word or phrase to search all 74 pages.

Ask The Pi-Hole Book

Answers come from this book only.

Talk to The Pi-Hole Book

Ask it out loud and it answers in your ear, from this book's own pages — the right command, the right setting, and the page it came from.

Unlock the tutor

Already bought it, or had an account on books.littlebird.com.au? Sign in.

Maddy, co-founder of Little Bird

Need help? We're here for you!

Hi, I'm Maddy. My team and I are ready to help with your order or any questions.