Shadowrocket Rules: Route Selected Websites with DOMAIN-SUFFIX and FINAL

Learn how to proxy selected websites and send all other traffic direct with DOMAIN-SUFFIX, DOMAIN-KEYWORD, and FINAL,DIRECT rules. Includes rule order and matching behavior.

At a glance

In [Rule], list the domains to proxy first and finish with FINAL,DIRECT. Then set Home → Global Routing to Config. This guide is for users who have already added proxy entries. Steps use iPhone / iPad menus; on Mac, Windows, Android, or Linux, check your configuration using the same matching logic without relying on identical menu locations.

A minimal ruleset: proxy selected domains, send everything else direct

When you know a website's domain, use DOMAIN-SUFFIX first. It matches domain labels: both example.com and www.example.com match DOMAIN-SUFFIX,example.com,PROXY, but notexample.com does not. To cover multiple domains, listing them individually is usually easier to verify than using a broad keyword match.

[Rule]
DOMAIN-SUFFIX,example.com,PROXY
FINAL,DIRECT

These examples use sample domains to demonstrate the syntax. When replacing them, enter only the hostname—no https://, path, or port. For example, with https://www.example.com:443/help, the hostname to match is www.example.com, not /help or 443. A domain rule cannot proxy one page and send another page on the same host direct.

Rule order: handle exceptions before broader matches

In Config mode, rules are generally checked from top to bottom. Once a rule matches, its policy applies; later rules do not change the result. To send one specific host direct while proxying other hosts in the same domain, put the exact-match DOMAIN rule before the broader DOMAIN-SUFFIX rule.

Request receivedTarget identifiedRule matchedOutbound selected
[Rule]
DOMAIN,status.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
DOMAIN-KEYWORD,docs-lab,PROXY
FINAL,DIRECT
Expected matches for the four rules above
Request hostFirst matching ruleOutbound
status.example.comExact match: DOMAINDIRECT
www.example.comSuffix match: DOMAIN-SUFFIXPROXY
docs-lab.example.netKeyword match: DOMAIN-KEYWORDPROXY
example.orgFallback: FINALDIRECT

DOMAIN-KEYWORD checks whether the hostname contains the specified string. The string does not need to be a complete label, and the rule is not limited to a particular domain. For example, a rule intended to match docs-lab.example.net would also match not-docs-lab.example.org. If you only need to cover a specific domain or domain range, remove the keyword rule and list the relevant DOMAIN or DOMAIN-SUFFIX rules instead.

Setup: enable Config under Global Routing

  1. Keep the original configuration

    Open Config, note the filename currently in use, and keep the original file. Test changes in a separate local copy. If the original file is updated from a remote configuration, avoid editing it directly so a future update does not overwrite your changes.

  2. Edit the rules section

    Add the target domain rules to the [Rule] section in your test copy, then set the fallback to FINAL,DIRECT. If a FINAL rule already exists, edit that line instead of adding another one. Also check whether earlier rules already match the target domain.

  3. Select the test configuration

    After saving, return to Config and confirm that the file you just edited is active. Editing a copy does not change the older configuration that is still in use.

  4. Switch the routing mode

    Open Home → Global Routing and select Config. On Home, confirm that a proxy entry is available, then turn on the connection. When troubleshooting, make sure the mode is not Proxy, Direct, or Scene; otherwise, the expected results for these rules may not reflect the current outbound selection.

  5. Test both routes separately

    Use real domains you can access and whose expected outbound routes are clear: one to test PROXY and another to test DIRECT. After changing the rules, start new connections. If an existing page is still using an open connection, close the relevant app and reopen it before testing again. If request logs are available, check the hostname and actual policy against the request time instead of relying only on whether the page loads.

In a configuration that retains existing rules, FINAL,DIRECT only handles requests that did not match an earlier rule. Existing GEOIP, IP-CIDR, and other rules still apply their own policies if they match first. To check whether an issue comes from an older rule, temporarily keep only necessary exceptions, target domain rules, and FINAL in a test copy. Verify both routes, then restore the original rules one at a time.

Troubleshooting: a rule matches, but the website won't load

First, distinguish which outbound was selected from whether that outbound is working. A browser error tells you where a request failed; by itself, it does not prove that the request used PROXY or DIRECT. The following are examples of messages a browser may display, not Shadowrocket-specific alerts.

Error: ERR_NAME_NOT_RESOLVED

Cause: The browser could not resolve the hostname for this request. Fix: Check whether the failing hostname is in the address bar, appears after a redirect, or belongs to a resource. If the hostname is correct, check the DNS settings in use. Do not try to fix a resolution failure just by broadening the domain match.

Error: ERR_CONNECTION_TIMED_OUT

Cause: The connection to the target was not established before the timeout. The selected outbound or target service may not be responding. Fix: Test the same outbound with another target known to work. If multiple targets time out on the same outbound, troubleshoot that outbound first rather than rewriting the fallback policy.

FAQ: subdomains, page resources, and direct-routing scope

How can I proxy one subdomain without affecting the whole website?

Use DOMAIN,api.example.com,PROXY. This matches only api.example.com; it does not also match www.example.com or v2.api.example.com. Check whether an earlier rule already covers this host.

The homepage loads, but sign-in keeps spinning. Which rule should I add?

Find the actual hostname used by the sign-in redirect or failed request first. Sign-in, API calls, and static assets may use different domains, which are not automatically covered by a rule for the main site. Once you confirm a host needs the same outbound, add a separate DOMAIN rule, save, and try again. Do not proxy every domain containing login.

Does FINAL,DIRECT mean traffic no longer passes through Shadowrocket?

No. DIRECT selects a direct outbound for a request that is already being routed; it does not turn off the connection or change the device's system routing. To compare behavior with the client turned off, disable the connection on Home and make a new request. If Settings → On Demand is enabled, also check that its conditions have not reconnected the client.

Why didn't a domain rule match when I used an IP address?

If the request target is an IP address, DOMAIN-SUFFIX cannot match it as though it were a domain. For a fixed IPv4 address that needs separate handling, use an exact IP-CIDR rule, such as IP-CIDR,192.0.2.10/32,PROXY, before the fallback. This address is only a syntax example. For websites using shared or dynamic IPs, route by the actual hostname instead.

Download Shadowrocket for all platforms