RedirectResponse
Class RedirectResponse.
Description
Represents an HTTP redirect response with customizable status codes for temporary or permanent redirects. This class MUST be used for generating HTTP responses that instruct clients to navigate to a different location, by automatically setting the 'Location' header.
Methods
Constructs a new RedirectResponse instance.
Constructs a new RedirectResponse instance.
public
__construct(
string|UriInterface
$uri[,
bool
$permanent = false][,
array<string|int, mixed>
$headers = []]) : mixed
Description
This constructor SHALL set the 'Location' header and apply the appropriate HTTP status code for temporary (302 Found) or permanent (301 Moved Permanently) redirects.
Parameters
$uri
:
string|UriInterface
Description
The target URI for redirection. MUST be absolute or relative according to context.
$permanent
:
bool
=
false
Description
if true, the response status will be 301 (permanent redirect); otherwise, 302 (temporary redirect)
$headers
:
array<string|int, mixed>
=
[]
Description
optional additional headers to include in the response