If you’re adding an exception to an existing configuration or requests still take the old route after you save your rules, first check the active configuration and Global Routing. Then find the first matching rule from the top of [Rule]. The examples below show where to place exceptions, how FINAL chooses a policy, and how to tell a rule match from a connection failure.
Rules are checked from top to bottom: the first match wins
On iPhone or iPad, select Home → Global Routing and choose Config, then check the active configuration on the Config page. If Global Routing is set to Proxy or Direct, the configuration rules below won’t determine the request route. If you use Scene, first check the routing settings for the active scene.
In Config mode, Shadowrocket evaluates the lines in [Rule] in order. The first matching rule determines the policy; later rules aren’t considered for that decision. A narrower match doesn’t automatically take priority: if a rule for an entire domain appears before a rule for one subdomain, the earlier rule can match that subdomain first. A connection failure after a match also doesn’t mean Shadowrocket will try the next rule.
FINAL,PROXY has no match valuePROXY, DIRECT, and REJECTWriting rules: put specific exceptions before broader matches
The [Rule] section below shows how to reject connections to one subdomain, connect directly to another, and proxy other destinations under the same domain. The example domains and addresses illustrate matching behavior; whether their websites open doesn’t indicate whether your configuration is correct. When editing an existing configuration, merge the rules into its existing [Rule] section. Don’t add a second rule section or another fallback.
[Rule]
DOMAIN,telemetry.example.com,REJECT
DOMAIN,docs.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.0.2.0/24,DIRECT
FINAL,DIRECT
telemetry.example.commatches the first line and usesREJECT;docs.example.commatches the second line and usesDIRECT. Neither is checked against the later suffix rule.- Both
example.comandwww.example.commatchDOMAIN-SUFFIX,example.com,PROXY;notexample.comdoesn’t have that domain suffix.DOMAINrequires an exact hostname match and doesn’t include deeper subdomains. - A connection to
192.0.2.10can match the example’sIP-CIDRrule. That rule andFINALboth useDIRECT, so the outbound policy alone won’t tell you which rule matched. Check the match record as well.
If you move DOMAIN-SUFFIX,example.com,PROXY above the two exceptions, both telemetry.example.com and docs.example.com will use PROXY. To add an exception, find the first rule in the configuration that covers the destination—not just FINAL and a place to insert a rule above it.
Choosing PROXY, DIRECT, REJECT, and FINAL
FINAL is a fallback rule, not a fourth policy. It applies only when no earlier rule matches, and its specified policy is then used. It’s generally best to keep one FINAL rule at the end. If your configuration also uses GEOIP or a broad IP-CIDR rule for routing, place domain exceptions that need higher priority before those broad rules. GEOIP,CN,DIRECT checks the destination IP’s geographic location, not whether the domain ends in .cn, and doesn’t guarantee the destination can be reached directly.
Match results and handling destinations with no matching rule
The three policies applied after a match
PROXY- Routes the connection through a proxy configured for outbound traffic. A working proxy must already be available.
DIRECT- Routes the connection without a proxy. Reachability depends on the current network.
REJECT- Rejects matching connections. It doesn’t filter content by webpage text or URL path.
A rule match means a policy was selected; it doesn’t mean the proxy handshake or destination connection succeeded.
Three ways to handle unmatched destinations
FINAL,DIRECT- Unmatched destinations connect directly by default. This is useful when only explicitly listed destinations should use a proxy.
FINAL,PROXY- Unmatched destinations use a proxy by default. List destinations that should connect directly above broader rules.
FINAL,REJECT- Unmatched destinations are rejected by default. When testing an allowlist, check dependencies such as DNS, sign-in, and resource domains.
These three lines are alternatives; don’t add them all to the same ruleset.
Changing FINAL,DIRECT to FINAL,PROXY affects only connections that didn’t match any earlier rule. If a destination already matches an earlier DIRECT rule, edit that rule or add a more specific exception above it. Changing only the fallback won’t change the result.
Testing rules: distinguish no match from an outbound failure
Keep the network and selected proxy unchanged while testing, and change only one rule at a time. A page may reuse an existing connection or load resources from multiple hosts, so its appearance after a refresh alone can’t confirm whether a rule took effect.
- Keep a copy of the original configuration. Edit and save a test configuration on the
Configpage, confirm that the edited configuration is active, then checkConfigunderHome → Global Routing. - Choose one destination covered by an exception, one covered by a broad rule, and one expected to use the fallback. Replace the example domains with destinations you can test, close existing connections, and start a new connection to each one. For HTTPS, for example, check the requested hostname and the destination port commonly used for HTTPS,
443, in the request record. - Find the matching time and destination in Shadowrocket’s connection records, then check the matched rule and outbound policy. If a broad rule still matches, check the top of
[Rule]for an earlier match. If the record showsPROXYbut the connection times out, run an initial proxy check atHome → Connectivity Test, then check whether the destination is reachable. A successful test doesn’t mean the proxy can reach every destination. - If the problem persists after restoring the original rules, don’t keep rearranging them to troubleshoot. Check the current network, the destination’s DNS resolution, and the proxy status first, then test the same destination again.
Common questions about custom rules
Troubleshoot by symptom
Why isn’t my new DIRECT rule taking effect?
First check the routing mode and active configuration, then use the connection record to see which rule actually matched. If an earlier DOMAIN-SUFFIX rule covers the destination, move the specific DOMAIN exception above it and test with a new connection.
Why does a domain connect directly, but its IP address use a proxy?
A direct connection to an IP address won’t necessarily match the domain rule you were using. Check the destination address in the connection record, then decide whether to add a separate IP-CIDR rule. Use /32 for a single IPv4 address; don’t route an entire subnet directly just to test.
Why can I still see page content after adding REJECT?
Check which hostname was rejected and compare it with requests that still loaded successfully. The page may be using cached content or loading resources from other hosts. If the content you want to block and the app’s API share a hostname, a domain rule can’t reject only one path. Widening the match may disrupt normal functionality.
Should I enter the full URL or just the hostname?
For DOMAIN and DOMAIN-SUFFIX, enter only a hostname or domain suffix. For https://docs.example.com:443/help, enter docs.example.com—without the scheme, port, or path. If the request redirects, check separately whether the new hostname needs a rule.