If custom rules aren’t taking effect, first make sure Global Routing is set to Config, then check which rule matches first. This guide is for readers who already have a Shadowrocket configuration enabled and want to add exceptions for specific domains. The examples show how to place a rule for a specific hostname before a domain-suffix rule, then verify that FINAL handles only the remaining requests.
Rule order: the first match determines the policy
In Config routing mode, Shadowrocket processes connections against the [Rule] section of the active configuration. Matching starts with the first rule. Once a rule matches, evaluation stops for that request. A later rule won’t override the result just because its conditions are more specific.
For example, DOMAIN-SUFFIX,example.com,PROXY matches both example.com and files.example.com. To connect files.example.com directly, place DOMAIN,files.example.com,DIRECT before the suffix rule. If the order is reversed, the suffix rule matches the subdomain first and sends it to PROXY.
Matching a rule and connecting successfully are two different things. If a request matches PROXY but the connection times out, Shadowrocket won’t continue to FINAL,DIRECT. When troubleshooting, first identify the matched rule, then check whether the selected policy’s outbound is available.
Rule syntax: conditions, match values, and policies
Rules with conditions typically use the format “type, match value, policy,” with fields separated by English commas. DOMAIN matches an exact hostname. DOMAIN-SUFFIX matches a domain and its subdomains, but not unrelated domains that merely end with the same characters. Enter a hostname in the domain field—without https://, a port, or a path.
Domain conditions
DOMAINfiles.example.com,DIRECTDOMAIN-SUFFIXexample.com,PROXY- Order
- Put exact-hostname exceptions first, followed by the suffix rule that would otherwise match them.
These two rule types don’t distinguish between different paths on the same hostname.
Address conditions and fallback
IP-CIDR192.0.2.0/24,DIRECTGEOIPCN,DIRECTFINALPROXY
The first two conditions check the destination IP. The last rule has no match value.
IP-CIDR checks whether the destination IPv4 address falls within a specified subnet. GEOIP matches the destination IP’s geographic location, not the device’s location, and doesn’t check whether the domain ends in .cn. When a domain request reaches an address-based rule, the destination domain may need to be resolved. The same domain can resolve to different addresses on different networks, so use a domain rule when you need consistent handling for a specific hostname.
Rule order example: domain exceptions, IP ranges, and FINAL
Place exceptions before broader rules in the same scope, then put FINAL at the end. The example below uses example domains and documentation-only IP ranges to illustrate how rules are evaluated. If your configuration already has a [Rule] section, edit that section instead of adding another header.
[Rule]
DOMAIN,blocked.example.com,REJECT
DOMAIN,files.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.0.2.0/24,DIRECT
GEOIP,CN,DIRECT
FINAL,PROXY
blocked.example.commatches the first rule and is rejected without reaching the suffix rule.files.example.commatches the second rule and connects directly, without being affected by the suffix rule below it.www.example.commatches neither exact-hostname rule, so the suffix rule sends it toPROXY.- A connection to
192.0.2.34matches the subnet rule and usesDIRECT. This address is for illustrating subnet matching, not for testing service availability. - Requests that don’t match any of the first four rules and have a destination IP geolocated to
CNuseDIRECT. Only requests that still haven’t matched reachFINAL,PROXY.
Don’t add rules below FINAL. By the time a request reaches that line, it already has a policy, so later rules can’t process it. If the existing configuration contains a broad match, check the rules above the insertion point too—not just whether the new rule is before FINAL.
Choosing a policy: PROXY, DIRECT, or REJECT
PROXY- Connect through a proxy outbound. Before using this policy, check in
Homethat an available outbound is provided by a service configuration you already have. DIRECT- Connect directly to the destination without using a proxy outbound. This applies to a single rule; it doesn’t disconnect Shadowrocket.
REJECT- Reject the connection. The requesting app may show a network error or retry on its own. Seeing some page content doesn’t prove that every domain it relies on is reachable.
Choose what happens to unmatched requests
To proxy only destinations you explicitly list, use FINAL,DIRECT for a default direct connection. To proxy destinations that aren’t listed, use FINAL,PROXY. Before changing the fallback, choose a test destination that matches none of the earlier conditions and use it to verify the result.
After editing: verify the configuration, routing mode, and new connections
- In
Config, confirm which configuration is active. Before editing, save a copy of the original and change only the lines you want to test. After saving, reopen the configuration and check the rule order. - Return to
Home, openGlobal Routing, and selectConfig. When troubleshooting an individual rule, don’t leave routing set to globalProxyorDirect. If you were usingScene, note the original setting before switching toConfigfor the test. - Use destinations you’re authorized to test. Check an exact-hostname exception, another hostname covered by the suffix rule, and a destination that matches none of the preceding conditions. Change one rule at a time so you can tie each result to a specific edit.
- Have the test app establish a new connection, then review the connection records in Shadowrocket. First confirm the hostname or destination IP actually requested, then check which policy was used. Simply refreshing a page may reuse an existing connection or load cached content.
When testing an HTTPS page, the connection record may show destination port 443, but the example domain rules match hostnames, not ports. If the page redirects, the final hostname may differ from the address you entered. Use the actual connection record to verify the result, not the text originally entered in the address bar.
FAQ: Why haven’t my saved rules changed the result?
I added DIRECT. Why is this subdomain still using PROXY?
First, confirm Config is selected under Home → Global Routing. Then check whether a DOMAIN-SUFFIX rule above the DOMAIN exception already matches the hostname. Move the exception above the broader rule, then test with a new connection.
I changed only FINAL. Why hasn’t this website’s policy changed?
Check whether an earlier domain rule already matches, then see if the destination IP is matched first by IP-CIDR or GEOIP. To test FINAL, use a destination that meets none of those conditions; there’s no need to remove existing rules.
A rule matched. Why did part of the page still fail to load?
Check whether the failed request was for the page’s main document or for an image, script, or API request on another hostname. First confirm which policy the failed request actually used. If it used the expected policy, check whether that outbound is reachable. Don’t start by broadening the domain-suffix rule to cover more hosts.