Documentation

RedirectController
in package

Redirects a request to another URL.

Tags
author

Fabien Potencier fabien@symfony.com

final

Table of Contents

$httpPort  : mixed
$httpsPort  : mixed
$router  : mixed
__construct()  : mixed
__invoke()  : Response
redirectAction()  : Response
Redirects to another route with the given name.
urlRedirectAction()  : Response
Redirects to a URL.

Properties

Methods

redirectAction()

Redirects to another route with the given name.

public redirectAction(Request $request, string $route[, bool $permanent = false ][, bool|array<string|int, mixed> $ignoreAttributes = false ][, bool $keepRequestMethod = false ][, bool $keepQueryParams = false ]) : Response

The response status code is 302 if the permanent parameter is false (default), and 301 if the redirection is permanent.

In case the route name is empty, the status code will be 404 when permanent is false and 410 otherwise.

Parameters
$request : Request
$route : string

The route name to redirect to

$permanent : bool = false

Whether the redirection is permanent

$ignoreAttributes : bool|array<string|int, mixed> = false

Whether to ignore attributes or an array of attributes to ignore

$keepRequestMethod : bool = false

Whether redirect action should keep HTTP request method

$keepQueryParams : bool = false
Tags
throws
HttpException

In case the route name is empty

Return values
Response

urlRedirectAction()

Redirects to a URL.

public urlRedirectAction(Request $request, string $path[, bool $permanent = false ][, string|null $scheme = null ][, int|null $httpPort = null ][, int|null $httpsPort = null ][, bool $keepRequestMethod = false ]) : Response

The response status code is 302 if the permanent parameter is false (default), and 301 if the redirection is permanent.

In case the path is empty, the status code will be 404 when permanent is false and 410 otherwise.

Parameters
$request : Request
$path : string

The absolute path or URL to redirect to

$permanent : bool = false

Whether the redirect is permanent or not

$scheme : string|null = null

The URL scheme (null to keep the current one)

$httpPort : int|null = null

The HTTP port (null to keep the current one for the same scheme or the default configured port)

$httpsPort : int|null = null

The HTTPS port (null to keep the current one for the same scheme or the default configured port)

$keepRequestMethod : bool = false

Whether redirect action should keep HTTP request method

Tags
throws
HttpException

In case the path is empty

Return values
Response

Search results