What is the difference between Set Path and Set Path + Query?
Short answer
Set Path changes only the path of the request; the original query string (?q=...) is preserved. Set Path + Query rewrites the path and the query string together; the value written in the New Path Info field also determines the query string, and the original parameters are preserved only if the Request Query variable is added. Both work only on the HTTP vService, at the request stage, and do not redirect the client; Location Redirection is used to send the client to another address.
How Does It Work?
A request address consists of two parts: the path (/search) and the query string (?q=laptop). Both actions rewrite the request before forwarding it to the Backend Service; the difference is which part is replaced with the New Path Info value.
- The request arrives with the
/search?q=laptopaddress. - If Set Path runs, only the
/searchpart is replaced with the New Path Info value;?q=laptopstays as it is. - If Set Path + Query runs, the whole
/search?q=laptopaddress is replaced with the New Path Info value; if the value contains no query, the query is deleted. - The request goes to the Backend Service with the new address; the address bar of the client does not change, and the next actions in the Actions list continue to run.
Comparison
| Set path | Set Path + Query | |
|---|---|---|
| What it changes | Only the path | The path and the query string |
| Original query string | Preserved | Replaced with the written value; deleted if the value contains no query |
| Field | New Path Info (default /prefix + Path variable) | The same field and the same default; since the default value does not contain Request query, the query is deleted if Request query is not added when the value is written manually |
| Path Operation Shortcuts | Available | Available; Request query is appended to the end of the expression produced by the shortcut |
/search?q=laptop, value /api/search | /api/search?q=laptop | /api/search |
/search?q=laptop, value /api/search + Request query | - | /api/search?q=laptop |
/search?q=laptop, value /api/search?format=json | - | /api/search?format=json (the q parameter is deleted) |
| Common | HTTP vService, only On request, condition optional, Hit counter, does not terminate the request | Same |
Set Path and Set Path + Query in TR7
- Both actions are selected from the Action Type list with Load Balancer → Actions → Add; the form is the same: New Path Info (required), Path Operation Shortcuts, Conditions, Hit Counter (off by default).
- There is no Execution level field; both work only at the request stage.
- The action takes effect when it is added to the Actions field of the vService; for the step-by-step setup, see Can I rewrite the URL path before it reaches the backend (rewrite)?
- The Path and Path + Query conditions and HTTP Logs see the address as it was before it was rewritten; the new address is verified in the log of the Backend Service.
When to Use Which?
- Set path: Tasks that concern only the path, such as adding or removing a prefix or changing the version path.
- Set path + query: Tasks that require adding or removing parameters or rearranging the query string; for example, adding
format=jsonto every request.
Common Misconceptions
- "Set path + query preserves the query string on its own." If the Request query variable is removed from the value, the original parameters are lost.
- "A
?is written before the Request query variable." The variable starts with?; if another?is written before it,??is produced (New Path Info). - "These actions send the client to the new address." Only the request going to the Backend Service changes; Location redirection is used to redirect the client.
- "The rewritten address appears in the TR7 logs." HTTP Logs shows the original address sent by the client.
How it is done in the documentation
