Rewriting URL instead of blocking · 2018-05-18 18:17 by Hubert Figuière
Starting with Adblock Plus 3.2 for Chrome, Firefox and Opera (and development builds as of 126.96.36.1993), there is a new
$rewrite filter option to rewrite the URL of a resource instead of blocking it.
When Adblock Plus matches a request URL with a filter that has the
$rewrite option, it will transform the URL following the provided rule, and tell the browser to load the resource using this new URL instead.
The syntax of the rewrite rule is as follow: you specify a string that serves as a template for the new URL.
$rewrite filters are ignored for requests of the type
OBJECT_SUBREQUEST, for security reasons.
This option is convenient to modify or strip query parameters.
This will simply rewrite the requests for “example.com/ad.gif” to be a request for “example.com/puppies.gif”
This will rewrite the request to example.com/page-123.php stripping the query string:
$1 matches “example.com/page-123.php”.
The will remove the “tracker” query parameter from the request URL.