Chrome extension to redirect specific URLs using chrome.declarativeNetRequest.updateDynamicRules and regexSubstitution
17:54 08 Jan 2026

I'm developing an extension that redirects specific URLs. I'm using chrome.declarativeNetRequest.updateDynamicRules to create dynamic rules like one that is presented down below. Then my extension can read that URL including all parameters. I expect that test.html is requested then in the following way:

chrome-extension://dasdsdasdnbbqswqdknciwncins/test.html?url=https://example.com?param1=value1...

Then i can read that URL using javascript. Unfortunately test.html is requested without parameters:

chrome-extension://dasdsdasdnbbqswqdknciwncins/test.html

If i will change test.html to some not existing page for example test1.html i see parameters in the browser address bar as expected:

chrome-extension://dasdsdasdnbbqswqdknciwncins/test1.html?url=https://example.com?param1=value1...

What could be a problem?

Dynamic rule

[
    {
        "action": {
            "redirect": {
                "regexSubstitution": "chrome-extension://dasdsdasdnbbqswqdknciwncins/test.html?url=\\0"
            },
            "type": "redirect"
        },
        "condition": {
            "regexFilter": "(^http.*example\\.com.*$)",
            "resourceTypes": [
                "main_frame"
            ]
        },
        "id": 1,
        "priority": 1
    }
]
google-chrome-extension chrome-declarativenetrequest