$removeheader
Rules with $removeheader modifier are intended to remove headers from HTTP requests and responses. The initial motivation for this rule type is to be able to get rid of the Refresh header which is often used to redirect users to an undesirable location. However, this is not the only case where this modifier can be useful.
Just like $csp, $redirect, $removeparam, and $cookie, this modifier exists independently, rules with it do not depend on the regular basic rules, i.e. regular exception or blocking rules will not affect it. By default, it only affects response headers. However, you can also change it to remove headers from HTTP requests as well.
Syntax
Basic syntax
||example.org^$removeheader=header-name -- removes a response header called header-name
||example.org^$removeheader=request:header-name -- removes a request header called header-name
Please note, that $removeheader is case-insensitive, but we suggest always use lower case.
Negating $removeheader
This type of rules works pretty much the same way it works with $csp and $redirect modifiers.
Use @@ to negate $removeheader:
@@||example.org^$removeheader -- negates all $removeheader rules for URLs that match ||example.org^.
@@||example.org^$removeheader=header -- negates the rule with $removeheader=header for any request matching ||example.org^.
$removeheader rules can also be disabled by $document and $urlblock exception rules. But basic exception rules without modifiers don't do that. For example, @@||example.com^ will not disable $removeheader=p for requests to example.com, but @@||example.com^$urlblock will.
Multiple rules matching a single request
In case if multiple $removeheader rules match a single request, we will apply each of them one by one.
Restrictions
- Please note that this type of rules can be used only in trusted filters. This category includes your own User filter and all the filters created by AdGuard Team.
- We don't want to lower the security level so
$removeheader cannot remove headers from the list below:
access-control-allow-origin
access-control-allow-credentials
access-control-allow-headers
access-control-allow-methods
access-control-expose-headers
access-control-max-age
access-control-request-headers
access-control-request-method
origin
timing-allow-origin
allow
cross-origin-embedder-policy
cross-origin-opener-policy
cross-origin-resource-policy
content-security-policy
content-security-policy-report-only
expect-ct
feature-policy
origin-isolation
strict-transport-security
upgrade-insecure-requests
x-content-type-options
x-download-options
x-frame-options
x-permitted-cross-domain-policies
x-powered-by
x-xss-protection
public-key-pins
public-key-pins-report-only
sec-websocket-key
sec-websocket-extensions
sec-websocket-accept
sec-websocket-protocol
sec-websocket-version
p3p
sec-fetch-mode
sec-fetch-dest
sec-fetch-site
sec-fetch-user
referrer-policy
content-type
content-length
accept
accept-encoding
host
connection
transfer-encoding
upgrade
$removeheader rules are not compatible with any other modifiers except $domain, $third-party, $app, $important, $match-case and content type modifiers (e.g. $script, $stylesheet, etc). The rules which have any other modifiers are considered invalid and will be discarded.
Examples
||example.org^$removeheader=refresh - removes Refresh header from all HTTP responses returned by example.org and it's subdomains.
||example.org^$removeheader=request:x-client-data - removes X-Client-Data header from all HTTP requests
- Removes
Refresh and Location headers from all HTTP responses returned by example.org save for requests to example.org/path/* for which no headers will be removed.
||example.org^$removeheader=refresh
||example.org^$removeheader=location
@@||example.org/path/$removeheader
$removeheaderRules with
$removeheadermodifier are intended to remove headers from HTTP requests and responses. The initial motivation for this rule type is to be able to get rid of theRefreshheader which is often used to redirect users to an undesirable location. However, this is not the only case where this modifier can be useful.Just like
$csp,$redirect,$removeparam, and$cookie, this modifier exists independently, rules with it do not depend on the regular basic rules, i.e. regular exception or blocking rules will not affect it. By default, it only affects response headers. However, you can also change it to remove headers from HTTP requests as well.Syntax
Basic syntax
||example.org^$removeheader=header-name-- removes a response header calledheader-name||example.org^$removeheader=request:header-name-- removes a request header calledheader-namePlease note, that
$removeheaderis case-insensitive, but we suggest always use lower case.Negating $removeheader
This type of rules works pretty much the same way it works with
$cspand$redirectmodifiers.Use
@@to negate$removeheader:@@||example.org^$removeheader-- negates all$removeheaderrules for URLs that match||example.org^.@@||example.org^$removeheader=header-- negates the rule with$removeheader=headerfor any request matching||example.org^.$removeheaderrules can also be disabled by$documentand$urlblockexception rules. But basic exception rules without modifiers don't do that. For example,@@||example.com^will not disable$removeheader=pfor requests toexample.com, but@@||example.com^$urlblockwill.Restrictions
$removeheadercannot remove headers from the list below:access-control-allow-originaccess-control-allow-credentialsaccess-control-allow-headersaccess-control-allow-methodsaccess-control-expose-headersaccess-control-max-ageaccess-control-request-headersaccess-control-request-methodorigintiming-allow-originallowcross-origin-embedder-policycross-origin-opener-policycross-origin-resource-policycontent-security-policycontent-security-policy-report-onlyexpect-ctfeature-policyorigin-isolationstrict-transport-securityupgrade-insecure-requestsx-content-type-optionsx-download-optionsx-frame-optionsx-permitted-cross-domain-policiesx-powered-byx-xss-protectionpublic-key-pinspublic-key-pins-report-onlysec-websocket-keysec-websocket-extensionssec-websocket-acceptsec-websocket-protocolsec-websocket-versionp3psec-fetch-modesec-fetch-destsec-fetch-sitesec-fetch-userreferrer-policycontent-typecontent-lengthacceptaccept-encodinghostconnectiontransfer-encodingupgrade$removeheaderrules are not compatible with any other modifiers except$domain,$third-party,$app,$important,$match-caseand content type modifiers (e.g.$script,$stylesheet, etc). The rules which have any other modifiers are considered invalid and will be discarded.Examples
||example.org^$removeheader=refresh- removesRefreshheader from all HTTP responses returned byexample.organd it's subdomains.||example.org^$removeheader=request:x-client-data- removesX-Client-Dataheader from all HTTP requestsRefreshandLocationheaders from all HTTP responses returned byexample.orgsave for requests toexample.org/path/*for which no headers will be removed.