B. Common Regex Patterns
Appendices
Here are some useful regex patterns commonly used with Pi-hole for domain blocking:
# Block all subdomains
^(.*\.)?example\.com$
# Block specific file types
.*\.(exe|mp4|zip)$
# Block domains starting with specific words
^(ad|ads|banner|pop|popup).*
# Block tracking domains
^track(er|ing)?\.
# Block analytics domains
^analytics?\.
# Block specific URL parameters
.*(\?|&)(utm_|fb_|ga_).*
# Block domains containing specific words
.*(stats|metric|telemetry).*
# Block domains ending with specific TLDs
.*\.(xyz|top|click)$
# Block numeric domains (often used by malware)
^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$
A few tips for using these patterns:
- Always test new regex patterns on a small scale first to avoid accidentally blocking legitimate domains
- The
^and$anchors are important - they ensure you match the entire domain - Remember that Pi-hole matches against the full domain name, so patterns need to account for that
- Use
.*sparingly as it can be resource-intensive
Would you like me to explain how any of these patterns work in more detail?
Something here not working for you? Ask in the community — other makers and the Little Bird team read it.