• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
2 SPDX-License-Identifier: curl
3 Long: location
4 Short: L
5 Help: Follow redirects
6 Protocols: HTTP
7 Category: http
8 Example: -L $URL
9 Added: 4.9
10 See-also: resolve alt-svc
11 Multi: boolean
12 ---
13 If the server reports that the requested page has moved to a different
14 location (indicated with a Location: header and a 3XX response code), this
15 option makes curl redo the request on the new place. If used together with
16 --include or --head, headers from all requested pages are shown.
17 
18 When authentication is used, curl only sends its credentials to the initial
19 host. If a redirect takes curl to a different host, it does not get the
20 user+password pass on. See also --location-trusted on how to change this.
21 
22 Limit the amount of redirects to follow by using the --max-redirs option.
23 
24 When curl follows a redirect and if the request is a POST, it sends the
25 following request with a GET if the HTTP response was 301, 302, or 303. If the
26 response code was any other 3xx code, curl resends the following request using
27 the same unmodified method.
28 
29 You can tell curl to not change POST requests to GET after a 30x response by
30 using the dedicated options for that: --post301, --post302 and --post303.
31 
32 The method set with --request overrides the method curl would otherwise select
33 to use.
34