File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,29 @@ Release Date: Unreleased
1212BREAKING
1313********
1414
15+ Behavior Changes
16+ ================
17+
18+ .. _v434-redirect-status-code :
19+
20+ Redirect Status Code
21+ --------------------
22+
23+ - Due to a bug, in previous versions, when using HTTP/1.1 or later the status
24+ code of the actual redirect response might be changed even if a status code was
25+ specified. For example, for a GET request, 302 would change to 307; for a POST
26+ request, 307 and 302 would change to 303.
27+ - Starting with this version, if you specify a status code in
28+ :ref: `redirect <response-redirect-status-code >`, that code will always be used
29+ in the response.
30+ - The default code for GET requests has been corrected from 307 to 302 when using
31+ HTTP/1.1 or later.
32+ - The default code for HEAD and OPTIONS requests has been corrected from 303 to
33+ 307 when using HTTP/1.1 or later.
34+ - In ``$routes->addRedirect() ``, 302 is specified by default. Therefor 302 will
35+ always be used when you don't specify a status code. In previous versions,
36+ 302 might be changed.
37+
1538Message Changes
1639***************
1740
Original file line number Diff line number Diff line change @@ -18,6 +18,13 @@ Mandatory File Changes
1818Breaking Changes
1919****************
2020
21+ Redirect Status Code
22+ ====================
23+
24+ - Due to a bug fix, the status codes of redirects may be changed. See
25+ :ref: `ChangeLog v4.3.4 <v434-redirect-status-code >` and if the code is not
26+ what you want, :ref: `specify status codes <response-redirect-status-code >`.
27+
2128Breaking Enhancements
2229*********************
2330
Original file line number Diff line number Diff line change @@ -109,6 +109,26 @@ When you want to redirect back, use ``redirect()->back()``:
109109 It takes a visitor to "the last page viewed during the Session" when the Session is available.
110110 If the Session hasn’t been loaded, or is otherwise unavailable, then a sanitized version of HTTP_REFERER will be used.
111111
112+ .. _response-redirect-status-code :
113+
114+ Redirect Status Code
115+ --------------------
116+
117+ The default HTTP status code for GET requests is 302. However, when using HTTP/1.1
118+ or later, 303 is used for POST/PUT/DELETE requests and 307 for all other requests.
119+
120+ You can specify the status code:
121+
122+ .. literalinclude :: ./response/032.php
123+ :lines: 2-
124+
125+ .. note :: Due to a bug, in v4.3.3 or previous versions, the status code of the
126+ actual redirect response might be changed even if a status code was specified.
127+ See :ref: `ChangeLog v4.3.4 <v434-redirect-status-code >`.
128+
129+ If you don't know HTTP status code for redirection, it is recommended to read
130+ `Redirections in HTTP <https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections >`_.
131+
112132.. _force-file-download :
113133
114134Force File Download
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ // Redirect to a URI path relative to baseURL with status code 301.
4+ return redirect ()->to ('admin/home ' , 301 );
5+
6+ // Redirect to a route with status code 308.
7+ return redirect ()->route ('user_gallery ' , [], 308 );
8+
9+ // Redirect back with status code 302.
10+ return redirect ()->back (302 );
You can’t perform that action at this time.
0 commit comments