Skip to content

Instantly share code, notes, and snippets.

@yuhangch
Last active August 31, 2023 03:42
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save yuhangch/9abc4220af46a1f4a7fc97393e2f040e to your computer and use it in GitHub Desktop.
Save yuhangch/9abc4220af46a1f4a7fc97393e2f040e to your computer and use it in GitHub Desktop.
cn.bing redirect to www.bing
{
"request": [
{
"enable": true,
"name": "bing-cn-to-www",
"ruleType": "redirect",
"matchType": "prefix",
"pattern": "https://cn.bing.com",
"exclude": "",
"group": "bing-redirect",
"isFunction": false,
"action": "redirect",
"to": "https://www.bing.com"
}
],
"sendHeader": [
{
"enable": true,
"name": "bing",
"ruleType": "modifySendHeader",
"matchType": "regexp",
"pattern": "^http(s?)://www\\.bing\\.com/(.*)",
"exclude": "",
"group": "bing-direct",
"isFunction": false,
"action": {
"name": "x-forwarded-for",
"value": "8.8.8.8"
}
}
],
"receiveHeader": [],
"receiveBody": []
}
@0ut0fcontrol
Copy link

0ut0fcontrol commented Feb 16, 2023

Using regex in request redirect to make search bar work.
Not redirect when go to next page by add (?!.*first=.*$)

{
	"request": [
		{
			"enable": true,
			"name": "bing-cn-to-www-search-bar",
			"ruleType": "redirect",
			"matchType": "regexp",
			"pattern": "^(?!.*first=.*$)http(s?):.*.bing.com\\/search\\?q=(.*?)&.*",
			"exclude": "",
			"group": "bing",
			"isFunction": false,
			"action": "redirect",
			"to": "https://www.bing.com/search?q=$2"
		},
		{
			"enable": false,
			"name": "bing-cn-to-www",
			"ruleType": "redirect",
			"matchType": "prefix",
			"pattern": "https://cn.bing.com",
			"exclude": "",
			"group": "bing",
			"isFunction": false,
			"action": "redirect",
			"to": "https://www.bing.com"
		}
	],
	"sendHeader": [
		{
			"enable": true,
			"name": "bing",
			"ruleType": "modifySendHeader",
			"matchType": "regexp",
			"pattern": "^http(s?)://www\\.bing\\.com/(.*)",
			"exclude": "",
			"group": "bing",
			"isFunction": false,
			"action": {
				"name": "x-forwarded-for",
				"value": "8.8.8.8"
			}
		}
	],
	"receiveHeader": [],
	"receiveBody": []
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment