To block requests from a distinct hostname, start with an exact DOMAIN rule; don’t block an entire site to stop a single resource. This guide is for users who can already enable a configuration in Shadowrocket. It covers rule order, testing, and rollback, and explains why domain rules cannot distinguish paths on the same HTTPS host.
How REJECT blocks requests during rule matching
REJECT is an action applied when a rule matches, not a matching condition. On iPhone or iPad, when Config is selected under Home → Global Routing, connections handled by the active rules are checked in order. If the first matching rule specifies REJECT, that connection is not forwarded via DIRECT or PROXY, and rule matching does not continue in search of an allowing rule.
A failed connection is an outcome, not proof that a rule matched. A browser may report a connection error, while an app may retry silently and make the page look unchanged. DNS failures and server outages can look similar. Conversely, resolving the target IP does not mean blocking failed: DNS resolution can succeed even when the subsequent connection is rejected.
Start with a before-and-after comparison
Before changing rules, confirm that both the target host and a control host that should remain accessible can connect. Test both again afterward. If only the target fails to load, you can’t tell whether the rule matched or the entire network is down.
DOMAIN vs. DOMAIN-SUFFIX: Syntax and rule order
DOMAIN matches an exact hostname, making it suitable for blocking a single confirmed resource host. DOMAIN-SUFFIX matches a domain and its subdomains, making it suitable for handling a group of hosts. Enter only the hostname in a rule—not https://, :443, or a path. The examples below use the reserved domain example.com; they do not imply that its example subdomains host accessible services.
[Rule]
DOMAIN,api.example.com,DIRECT
DOMAIN,events.example.com,REJECT
DOMAIN-SUFFIX,example.com,DIRECT
FINAL,DIRECT
In this example, events.example.com matches the exact reject rule first. img.events.example.com does not match that DOMAIN rule, so it reaches the later suffix rule with a direct policy. If you move the suffix rule above the exact reject rule, both hosts will be routed directly first. Exact rules are not automatically placed ahead of broader ones. When adapting this snippet for an existing configuration, keep the original FINAL; don’t replace your existing routing with the example’s direct fallback.
Block a single host
- Reject rule
DOMAIN,events.example.com,REJECT- Expected match
events.example.com- No match
img.events.example.com
Test the effect with an exact match first, then decide whether to broaden the rule.
Block a suffix while keeping an exception
- Add the exception first
DOMAIN,api.example.com,DIRECT- Add the reject rule next
DOMAIN-SUFFIX,example.com,REJECT- Expected result
api.example.comis routed directly; other hosts with the same suffix are rejected
This is a separate configuration; don’t combine it with the previous example that routes hosts with the same suffix directly.
Add a rule in Config and verify the result
The steps below use the iPhone / iPad interface. Edit a copy of your configuration first and change only one thing, so you can distinguish this rule change from DNS, connection-state, or other configuration changes.
- In
Config, confirm which configuration is in use and keep the original file. In the copy, find[Rule]. Place the exact reject rule before any broader rule that could match the target—not merely aboveFINAL. - Save and enable the modified configuration, return to
Hometo confirm the connection is on, then check thatConfigis selected underGlobal Routing. Don’t use results from forcingProxyorDirectto judge this configuration rule. - Replace the examples with two test hosts you control and confirmed were accessible before the change. Start fresh connections and test the target and control hosts separately; don’t rely on an already-open page, since caching or connection reuse can hide the change. If connection logs are available, check the target hostname and the policy actually applied.
- If the target is rejected and the control host still works, test any essential login, image-loading, or upload functions. If the control host fails too, switch back to the original configuration and test again. If that restores access, check the suffix rule’s scope and the order of its exceptions.
HTTPS and the limits of blocking embedded content on the same host
HTTPS encryption does not automatically make domain rules ineffective. If Shadowrocket can identify the destination hostname for a connection, it can still reject the entire connection by hostname. However, DOMAIN and DOMAIN-SUFFIX do not inspect URL paths, request bodies, or response content inside HTTPS. For a page and its resources on the same host, a domain rule cannot allow one path while blocking another.
| Request pattern | What a domain rule does | What to verify |
|---|---|---|
The page is on www.example.com; the resource is on events.example.com | If the hostname can be identified, you can reject only the resource host | Check the connection result for each host separately |
www.example.com/news and www.example.com/assets/widget.js | Same hostname: a rule cannot block the latter based on its path alone | Don’t put a path in DOMAIN, and don’t block an entire host to stop a single resource |
| The resource is already included in the page’s HTML | There is no separate resource connection to reject | Confirm that the page actually sends a request to a separate host |
| The app connects directly to the target IP without obtaining a hostname that can be matched | A domain rule may not match this connection | Check the actual connection target first; don’t immediately broaden the rule to an IP range |
REJECT does not rewrite the page, remove elements, or clean up the space they leave behind. Likewise, IP-CIDR is not an equivalent substitute for a domain rule: if multiple sites share an IP address, rejecting that IP may also block sites you intended to keep accessible.
Troubleshooting REJECT rules that don’t work or block too much
Why can the target host still connect after I add a rule?
First, check that Config is selected under Home → Global Routing. Then open Config and confirm you edited the file currently in use. If the configuration is correct, check for an earlier matching DOMAIN-SUFFIX rule above the target, then test with a new connection.
Why is the content still visible after a domain rule matches?
Test again in a new page session. If the content is still there, check whether it came from a cache, a path on the same host, or a fallback host. Only after confirming that a separate fallback host exists and can be identified should you consider adding an exact rule for it.
Can I keep login working while blocking the rest?
Switch back to the original configuration first and confirm that login works again. If login uses a separate host, add an exact exception for that host before the suffix reject rule and preserve its existing outbound policy. If login and the resource you want to block share a host and differ only by path, remove the host-level reject rule.
On Demand is enabled, but nothing changed. What else should I check?
Settings → On Demand controls when a connection starts automatically; it does not change rule contents or priority. First check the connection status on Home and confirm that routing is set to Config, then review the rule order. Don’t keep toggling automatic connection to determine whether a rule is correct.
Get Shadowrocket and learn how to configure it
Get the iPhone / iPad version from the App Store for a one-time payment of $2.99; check the App Store listing for system requirements. The Mac (Apple Silicon / Intel), Windows, Android, and Linux versions are free. Getting the app and configuring traffic routing are separate things; this site does not provide, sell, or recommend proxy nodes or subscriptions.