Actions
Feature #19034
closedDirect HTTP redirections from QFQ
Start date:
07.07.2024
Due date:
08.07.2024
% Done:
0%
Estimated time:
Discuss:
Prio Planung:
No
Vote:
KP
Description
Currently a redirection is achieved with a JavaScript code. This has the following drawbacks:
- no redirection happen if JavaScript is disabled
- the whole page must be rendered by the server and by the browser before a redirection triggers
A better approach is to ask Typo3 to immediately send a 30x HTTP response with a location header.
This feature will improve- several redirections on SeminarLive page
- user authentication via QFQ
Keeping in mind a future migration to a different template engine, the code code should be template agnostic.
Updated by Krzysztof Putyra 10 days ago
Parameters
Notes
- location URL (required)
- HTTP status code (optional with a default value)
SELECT '...|r:9|h:307' AS _link
- no new special column
- the
link
column gets even more complicated
SELECT 'l:{{&link:R}}|c:307' AS _httpRedirect
- special column makes it easy to spot
- the link must be created before if sip parameters are to be used
SELECT '...' AS '_link|_httpRedirect(307)'
Currently the best choice seems to be 1. with 3. an improvement once the additional features are implemented.
HTTP code
Code | Type | What to be cached | 2nd request method |
---|---|---|---|
301 | Permanent | The final URL | may be changed |
308 | Permanent | The final URL | cannot be changed |
302 | Temporary | The original URL | may be changed |
307 | Temporary | The original URL | cannot be changed |
303 | Temporary | The original URL | must be changed to GET |
- Codes 307 and 308 were introduces after 301 and 302 to remove the ambiguity in handling the redirections: in case of 301 and 302 the specification said nothing about the request method for the second request and some user agents switches from POST to GET.
- 303 usually follows POST and PUT requests to deliver a page with results of an action. In such case repeating the POST or PUT request makes no sense and might be even confusing - the form is no longer visible.
Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
Updated by Krzysztof Putyra 10 days ago
Implemented:
- functionality in Link class using the first syntax
- rendering mode 9 triggers an exception RedirectResponse
- the exception is catched by QfqController and converted to PropagateResponseException to make Typo3 trigger the redirection
- default HTTP code: 303
- unit tests for the Link class
- no unit test for QfqController, but the functionality has been directed on a test website
- updated documentation
Actions