Regex filter on domain & sub-domain, am i doing it right?

I am try to whitelist this domain and sub-domain(not sure if i am using the correct term) using Regex, am i doing it right?

example of domain & sub-domains:


Your first example domain is actually a URL. The https part is the scheme used to connect to the following domain, Pi-hole will never see this part.

You also don't need to match the entire domain. Just matching a substring will work.

Thirdly, to match a literal dot (.) you need to escape it (\.), since the dot itself is used as a wildcard that matches any character.

You can simplify your regex to


^ and $ match the start and end if a line. That ensures you do not match nefarious domains like xxxgameserver.comyyy, but do match subdomains like (notice the dot after the subdomain).


is there a different between your and this?
still quite confuse on this regex

( \ .|^)$ * ignore spacing


Those are functionally the same. The first section inside the ()s is an OR statement. Either the word gameserver is at the start of the domain or is immediately preceeded by a dot. The order doesn't matter. You could also escape the dot before com.

(To mark text as code you can use the Preformatted Text button or code fences with backticks ` around the code to mark as formatted.)

could this code also block these:
i believe it could?

Test your regex at It has a good interface that will check your regex for validity and show if it does or does not match a domain and why.

You may also want to visit our regex tutorial:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.