Topic guides
DOMAIN-SUFFIX Rule Generator
Batch-convert domain suffixes into Clash or Mihomo DOMAIN-SUFFIX rules for custom routing lists.
On this page
When to use it
- You have a list of domain suffixes and need Clash or Mihomo rules.
- You want to route them to DIRECT, REJECT, Proxy, or a custom group.
- You want to avoid formatting mistakes when writing
DOMAIN-SUFFIXrules.
Tip
Choose domain suffix as the match type, paste domains line by line, set the target group, then generate rules.
Start with a suffix rule you can verify
DOMAIN-SUFFIX matches a domain and its subdomains, not an arbitrary substring. This Mihomo fragment sends example.com and its subdomains directly and rejects every other request. Its built-in DIRECT and REJECT targets need no custom group:
rules:
- DOMAIN-SUFFIX,example.com,DIRECT
- MATCH,REJECT
This is an educational fragment, not a complete client configuration. Do not replace your normal rules with it uncritically: the final rule rejects all unmatched traffic.
Enter it in the rule builder
Open Mihomo / Clash Rule Builder, add a domain-suffix rule, enter example.com and choose DIRECT. Enter a hostname only: no scheme, port, path or *.example.com. Generate rules first and inspect the result. To merge them, supply the existing configuration and review the insertion position.
To use a proxy, choose a group that actually exists in that configuration, such as PROXY. A different template may use a different name; select its real group or an available automatic target. Do not assume every template defines PROXY. Generating a workspace preview does not automatically overwrite saved account rules; saving preferences is a separate action.
Test the domain boundary
Paste the fragment into Rule Debugger and test these hostnames. This example has no IP or remote rule-set dependency:
| Hostname | Expected target | Reason |
|---|---|---|
example.com |
DIRECT |
The domain itself |
www.example.com |
DIRECT |
A subdomain |
notexample.com |
REJECT |
No domain-label boundary |
example.com.other.test |
REJECT |
A different suffix |
Use DOMAIN for one exact hostname such as www.example.com. Consider DOMAIN-KEYWORD only when you deliberately want substring matching, and check for unintended matches. Domain rules do not inspect web paths; they cannot target only a site's /video page.
When a correct rule appears ineffective
Mihomo evaluates rules in order. A broad MATCH above the suffix rule prevents it from being reached. More specific exceptions should precede general suffix rules. Inspect the configuration the client actually loaded, not only the text you just generated.
A missing-target error means you should compare the full group name, spaces and Emoji or choose an existing target in the tool. If offline debugging and a real connection differ, examine the hostname observed by the client, sniffing and DNS settings. Offline evaluation does not connect to the website or prove network access. Destination-IP country routing is a different condition, covered in GEOIP rules.