This method is a shortcut to [[Response::redirect()]].
You can use it in an action by returning the Response directly:
php
stop executing this action and redirect to login page
return $this->redirect(['login']);
public redirect ( string | array $url, integer $statusCode = 302 ) : |
||
$url | string | array | the URL to be redirected to. This can be in one of the following formats: - a string representing a URL (e.g. "http://example.com") - a string representing a URL alias (e.g. "@example.com") - an array in the format of `[$route, ...name-value pairs...]` (e.g. `['site/index', 'ref' => 1]`) [[Url::to()]] will be used to convert the array into a URL. Any relative URL will be converted into an absolute one by prepending it with the host info of the current request. |
$statusCode | integer | the HTTP status code. Defaults to 302.
See |
return | the current response object |