The way we incorporate redirecting should preserve the URL context (either ens:// or ipfs:// etc). This would also allow decentrally-hosted sites to persist cookies even after the gateway is changed.
I think that API may be webRequest.onBeforeRequest().
That work can build on #7362, and should also be useful for the snaps system.