Rule Specification

Gooreplacer uses a plain-text rule format — readable, version-control friendly, and editable with any text editor.

Specification

[filter],[filter_type],[action]
[condition]+
[action_options]+

Empty lines or lines starting with # act as rule delimiters.

Fields

Field Description
filter URL pattern to match against
filter_type wildcard or regex
action block, redirect, or modifyHeaders

Conditions

Format: condition:key=value. Can be repeated for multiple conditions.

Condition Meaning
initiatorDomains Only match requests originating from these domains (comma-separated)
excludedInitiatorDomains Exclude requests from these domains (takes precedence over initiatorDomains)
requestDomains Only match when request domain is in this list
isUrlFilterCaseSensitive Case-sensitive filter matching (default: false)
resourceTypes Match specific resource types
excludedResourceTypes Exclude specific resource types
requestMethods Match specific HTTP methods

Action Options

block

No options required.

redirect

  • url:[url] — Static redirect URL
  • regexSubstitution:[url] — Dynamic URL with capture groups (\1 to \9)
  • transform:k1=v1,k2=v2 — Transform URL parts: host, path, query, scheme (see URLTransform)

modifyHeaders

Format: [type]:[operation]:key=value

  • type: requestHeaders or responseHeaders
  • operation: set, append (response only), or remove

Filter Types

Wildcard

Supported constructs for wildcard patterns:

Construct Meaning
* Wildcard — matches any number of characters
| Left/right anchor — beginning or end of the URL
|| Domain anchor — start of a (sub-)domain
^ Separator — matches anything except letters, digits, _ - . %

Examples

urlFilter Matches Does not match
abc https://abcd.com, https://example.com/abcd https://ab.com
abc*d https://abcd.com, https://example.com/abcxyzd https://abc.com
||a.example.com https://a.example.com/, https://b.a.example.com/xyz https://example.com/
|https* https://example.com http://example.com/
Note: The urlFilter must be composed of only ASCII characters. Internationalized domains are matched in punycode format, and non-ASCII characters are URL-encoded in UTF-8.

See Chrome URL filter syntax docs for full details.

Regex

Regular expression matching using RE2 syntax. Use regexSubstitution with capture groups (\1 to \9, \0 for full match).

^https://www\.(abc|def)\.xyz\.com/,regex,redirect
regexSubstitution:https://\1.xyz.com/

This redirects https://www.abc.xyz.com/path to https://abc.xyz.com/path.

Writing Good URL Conditions

Take care to always match an entire domain. Common mistakes:

Pattern Problem
google.com Matches https://example.com/?param=google.com
||google.com Matches https://google.company
https://www.google.com Matches https://example.com/?param=https://www.google.com

Better alternatives:

Header Modification

According to Chrome docs, the append operation is only supported for these headers:

accept accept-encoding accept-language access-control-request-headers cache-control connection content-language cookie forwarded if-match if-none-match keep-alive range te trailer transfer-encoding upgrade user-agent via want-digest x-forwarded-for

Complete Example

# Block example.com main frame for specific initiators
example.com,wildcard,block
condition:resourceTypes=main_frame
condition:isUrlFilterCaseSensitive=true
condition:initiatorDomains=google.com,x.com
condition:requestMethods=get,post

# Modify headers on liujiacai.net
liujiacai.net,wildcard,modifyHeaders
responseHeaders:append:x-forwarded-for=129.9.9.1
requestHeaders:set:user-agent=gooreplacer