You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/general/ad-filtering/create-own-filters.md
+30-15Lines changed: 30 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2942,7 +2942,7 @@ Rules with `$replace` modifier are supported by AdGuard for Windows, AdGuard for
2942
2942
2943
2943
#### **`$urltransform`** {#urltransform-modifier}
2944
2944
2945
-
The `$urltransform` rules allow you to modify the request URL by replacing text matched by a regular expression.
2945
+
The `$urltransform` rules allow you to modify the request URL by applying a series of transformations.
2946
2946
2947
2947
**Features**
2948
2948
@@ -2954,7 +2954,8 @@ The `$urltransform` value can be empty for exception rules.
2954
2954
2955
2955
**Multiple rules matching a single request**
2956
2956
2957
-
If multiple `$urltransform` rules match a single request, we will apply each of them. **The order is defined alphabetically.**
2957
+
If multiple `$urltransform` rules match a single request, they are applied one-by-one in lexicographical order, each
2958
+
rule being applied to the result of the previous one.
2958
2959
2959
2960
**Syntax**
2960
2961
@@ -2996,7 +2997,7 @@ This section only applies to AdGuard for Windows, AdGuard for Mac, AdGuard for A
2996
2997
:::
2997
2998
2998
2999
As stated above, normally `$urltransform` rules are only allowed to change the path and query parts of the URL.
2999
-
However, if the rule's `regexp`begins with the string `^http`, then the full URL is searched and can be modified by the rule.
3000
+
However, if the value of the `$urltransform` modifier begins with the string `/^http`, then the full URL becomes the input for, and can be modified by, the rule.
3000
3001
Such a rule will not be applied if the URL transformation can not be achieved via an HTTP redirect (for example, if the request's method is `POST`).
3001
3002
3002
3003
**Examples**
@@ -3046,23 +3047,37 @@ Many websites use tracking URLs to monitor clicks before redirecting to the actu
3046
3047
3047
3048
Below is an example of how to obtain the clean destination link to bypass tracking websites and go directly to the destination.
3048
3049
3049
-
In our example:
3050
+
In our first example, the destination URL is percent-encoded:
3050
3051
3051
-
1. The initial URL (with click tracking): `https://www.aff.example.com/visit?url=https%3A%2F%2Fwww.somestore.com%2F%26referrer%3Dhttps%3A%2F%2Fwww.aff.example.com%2F%26ref%3Dref-123`
3052
-
1. Tracking URL after decoding special characters: `https://www.aff.example.com/visit?url=https://www.somestore.com/`
3053
-
1. The website you want to visit: `https://www.somestore.com`
3052
+
1. The initial URL (with click tracking): `https://www.aff.example.com/visit?url=https%3A%2F%2Fwww.somestore.com%2F&ref=ref-123`
3053
+
1. The website you want to visit: `https://www.somestore.com/`
3054
3054
3055
-
To clean the URL, we first need to decode special characters (like `%3A` → `:`, `%2F` → `/`, etc.) and extract the real URL from the tracking parameters. We will use the `$urltransform` modifier to do this. The following 4 rules replace URL-encoded symbols with their real characters:
3055
+
To clean the URL, extract the encoded destination from the `url` parameter and decode it with the `pct` transformation:
The first transformation extracts `aHR0cHM6Ly93d3cuc29tZXN0b3JlLmNvbS8/cmVmPXJlZi0xMjM=`, and `b64` decodes it to
3074
+
`https://www.somestore.com/?ref=ref-123`. The final substitution removes the `ref` tracking parameter.
3075
+
3076
+
:::caution Changing the origin
3077
+
3078
+
Note that in both rules, the `$urltransform` value starts with `/^http`, so the full request URL is transformed. Without this prefix, only the path and query parts of the URL can be transformed.
3079
+
3080
+
:::
3066
3081
3067
3082
Tracking links will now be automatically cleaned up, allowing direct navigation to the destination website without tracking.
0 commit comments