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.
| Status | Move | Method and body |
|---|---|---|
302 | Temporary | Clients may change POST to GET. |
307 | Temporary | Method and body preserved. |
308 | Permanent | Method 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.
Configure the redirect you need
Section titled “Configure the redirect you need”302: /old to /new
Section titled “302: /old to /new”{ "spec": { "routes": [ { "redirect_route": { "path": { "path": "/old" }, "route_redirect": { "proto_redirect": "https", "path_redirect": "/new", "response_code": 302 }, "http_method": "ANY" } } ] }}307: temporary POST destination
Section titled “307: temporary POST destination”{ "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.
Compare a fixed POST
Section titled “Compare a fixed POST”Verified live example: Open the application demo panel.
- Select POST through 307 to send a fixed synthetic body with
?sample=synthetic. - Inspect the echo: its method is POST, its body is preserved, and its query contains
sample=synthetic. - Select POST through 308 to send the same input through the permanent alternative.
- 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.
Automatic HTTP-to-HTTPS redirects
Section titled “Automatic HTTP-to-HTTPS redirects”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.
- Open the browser’s network inspector and select Preserve log.
- Navigate to
http://custom-responses.f5-sales-demo.com/demo/echo?sample=synthetic. - Inspect the first response: it should be
301withLocation: https://custom-responses.f5-sales-demo.com/demo/echo?sample=synthetic. - Inspect the HTTPS response: it should return
200with the synthetic echo andsample=syntheticquery.
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.
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.