xref: /aosp_15_r20/external/curl/docs/cmdline-opts/location.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: location
5*6236dae4SAndroid Build Coastguard WorkerShort: L
6*6236dae4SAndroid Build Coastguard WorkerHelp: Follow redirects
7*6236dae4SAndroid Build Coastguard WorkerProtocols: HTTP
8*6236dae4SAndroid Build Coastguard WorkerCategory: http
9*6236dae4SAndroid Build Coastguard WorkerAdded: 4.9
10*6236dae4SAndroid Build Coastguard WorkerMulti: boolean
11*6236dae4SAndroid Build Coastguard WorkerSee-also:
12*6236dae4SAndroid Build Coastguard Worker  - resolve
13*6236dae4SAndroid Build Coastguard Worker  - alt-svc
14*6236dae4SAndroid Build Coastguard WorkerExample:
15*6236dae4SAndroid Build Coastguard Worker  - -L $URL
16*6236dae4SAndroid Build Coastguard Worker---
17*6236dae4SAndroid Build Coastguard Worker
18*6236dae4SAndroid Build Coastguard Worker# `--location`
19*6236dae4SAndroid Build Coastguard Worker
20*6236dae4SAndroid Build Coastguard WorkerIf the server reports that the requested page has moved to a different
21*6236dae4SAndroid Build Coastguard Workerlocation (indicated with a Location: header and a 3XX response code), this
22*6236dae4SAndroid Build Coastguard Workeroption makes curl redo the request on the new place. If used together with
23*6236dae4SAndroid Build Coastguard Worker--show-headers or --head, headers from all requested pages are shown.
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard WorkerWhen authentication is used, or send cookie with `-H Cookie:`, curl only sends
26*6236dae4SAndroid Build Coastguard Workerits credentials to the initial host. If a redirect takes curl to a different
27*6236dae4SAndroid Build Coastguard Workerhost, it does not get the credentials pass on. See --location-trusted on how
28*6236dae4SAndroid Build Coastguard Workerto change this.
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard WorkerLimit the amount of redirects to follow by using the --max-redirs option.
31*6236dae4SAndroid Build Coastguard Worker
32*6236dae4SAndroid Build Coastguard WorkerWhen curl follows a redirect and if the request is a POST, it sends the
33*6236dae4SAndroid Build Coastguard Workerfollowing request with a GET if the HTTP response was 301, 302, or 303. If the
34*6236dae4SAndroid Build Coastguard Workerresponse code was any other 3xx code, curl resends the following request using
35*6236dae4SAndroid Build Coastguard Workerthe same unmodified method.
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard WorkerYou can tell curl to not change POST requests to GET after a 30x response by
38*6236dae4SAndroid Build Coastguard Workerusing the dedicated options for that: --post301, --post302 and --post303.
39*6236dae4SAndroid Build Coastguard Worker
40*6236dae4SAndroid Build Coastguard WorkerThe method set with --request overrides the method curl would otherwise select
41*6236dae4SAndroid Build Coastguard Workerto use.
42