跳到內容
Aa

Redirects

本頁內容尚未翻譯。

Move a resource while controlling request method, body and query handling. An explicit route moves a selected path; an automatic HTTP-to-HTTPS redirect changes the connection scheme for the host. Both return a status and Location; the destination application serves the final response.

Visitor response: A redirect followed by the destination response.

StatusMoveMethod and body
302TemporaryClients may change POST to GET.
307TemporaryMethod and body preserved.
308PermanentMethod and body preserved.

The 302 and 307 examples retain the query; the 308 example removes it. Removing the query is this example’s remove_all_params setting, not an inherent property of 308. Permanent redirects can be cached by clients.

{
"spec": {
"routes": [
{
"redirect_route": {
"path": {
"path": "/old"
},
"route_redirect": {
"proto_redirect": "https",
"path_redirect": "/new",
"response_code": 302
},
"http_method": "ANY"
}
}
]
}
}
{
"spec": {
"routes": [
{
"redirect_route": {
"path": {
"path": "/demo/temporary"
},
"http_method": "ANY",
"route_redirect": {
"proto_redirect": "https",
"path_redirect": "/demo/echo",
"response_code": 307,
"retain_all_params": {}
}
}
}
]
}
}

308: permanent POST destination with query removal

Section titled “308: permanent POST destination with query removal”
{
"spec": {
"routes": [
{
"redirect_route": {
"path": {
"path": "/demo/permanent"
},
"http_method": "ANY",
"route_redirect": {
"proto_redirect": "https",
"path_redirect": "/demo/echo",
"response_code": 308,
"remove_all_params": {}
}
}
}
]
}
}

These are alternatives on different paths, not sequential steps. The route_redirect object selects the destination and status within each route.

Verified live example: Open the application demo panel.

  1. Select POST through 307 to send a fixed synthetic body with ?sample=synthetic.
  2. Inspect the echo: its method is POST, its body is preserved, and its query contains sample=synthetic.
  3. Select POST through 308 to send the same input through the permanent alternative.
  4. Inspect the echo: POST and the body remain, but the query is empty.

The application panel runs on the destination’s own origin. Every action requires a click and reserves two requests against a twelve-request page budget. It reports the final echo; use the browser’s network inspector with Preserve log to inspect the initial status and Location.

Expected result: The first response matches the selected status and destination; the final echo confirms the method, body and query behavior. An unrelated path still reaches the origin.

Qualified direct links let you explore GET redirects, but they do not demonstrate POST preservation:

For metadata changes on the response instead of a move, see Headers and cookies.

Choose the host-wide redirect when HTTP requests should move to the same address over HTTPS (HTTP over Transport Layer Security). It runs at the load balancer’s HTTP listener, separately from the redirect routes above. In this example, https_auto_cert.http_redirect enables it.

{
"spec": {
"https_auto_cert": {
"http_redirect": true
}
}
}

Measured behavior: GET and POST requests to the HTTP echo address returned 301. The Location used HTTPS and retained the path and query. The trusted HTTPS destination returned 200; the direct origin returned 200 without a redirect.

A 301 does not guarantee POST method preservation when a client follows it. Start submission requests with HTTPS; changing this automatic redirect does not turn it into the 307 or 308 route alternatives.

  1. Open the browser’s network inspector and select Preserve log.
  2. Navigate to http://custom-responses.f5-sales-demo.com/demo/echo?sample=synthetic.
  3. Inspect the first response: it should be 301 with Location: https://custom-responses.f5-sales-demo.com/demo/echo?sample=synthetic.
  4. Inspect the HTTPS response: it should return 200 with the synthetic echo and sample=synthetic query.

Expected result: HTTP receives the host-wide redirect, while HTTPS reaches the application. If your browser upgrades HTTP before sending it, that navigation does not exercise the listener; use the fixed command below to inspect the first response without following it.

Terminal window
curl --silent --show-error --max-time 15 \
--dump-header - --output /dev/null \
'http://custom-responses.f5-sales-demo.com/demo/echo?sample=synthetic'

The sanitized live proof records the independent configuration, HTTPS and direct-origin controls. This redirect changes the destination, not the response body.