1

The declarativeNetRequest rule I set

[
  {
    "action": {
      "redirect": {
        "url": "https://another.com/api_2/luckyDog"
      },
      "type": "redirect"
    },
    "condition": {
      "requestMethods": ["get"],
      "urlFilter": "/luckyDog"
    },
    "id": 1
  }
]
  1. When http://current.com/api/luckyDog is requested, it was redirected to https://another.com/api_2/luckyDog. This is right.

  2. However when I request http://current.com/api/luckyDog?count=3, it was redirected to https://another.com/api_2/luckyDog too. I expect it to be redirected to https://another.com/api_2/luckyDog?count=3.

I don't know how to do that. Can someone help me ?

Yue
  • 11
  • 1

1 Answers1

1

Instead of url, which replaces the entire URL, specify the parts to replace explicitly:

      "redirect": {
        "scheme": "https",
        "host": "another.com",
        "path": "/api_2/luckyDog"
      },

Alternatively, use regexFilter + regexSubstitution, which is more flexible, but slower - see examples.

wOxxOm
  • 65,848
  • 11
  • 132
  • 136