Quick links: Content - sections - sub sections

There are two types of redirection objects available:

  • jResponseRedirect: redirects to an action of the application with optional parameters
  • jResponseRedirectUrl: redirects to any URL, in particularly external url.


To specify a redirection to an action, you indicate 'redirect' as the type of response:

$resp = $this->getResponse('redirect');

You have then an instance of jResponseRedirect in $resp.

You have three properties on this object:

  • action to indicate the action to redirect (an action selector)
  • params to indicate parameters for this actions (optional)
  • anchor to indicate an anchor in the url #anchor (optional)


$resp->action = "mymodule~mycontroller:mymethod";
$resp->params = array('foo' => 'bar');
$resp->anchor = 'yo';

And then

return $resp;

There is shortcut method on controllers: redirect($action, $parameters, $anchor).

return $this->redirect("monmodule~moncontroleur:mamethode", array('foo' => 'bar'), 'yo');


This type of response ("redirectUrl") is used to redirect to an external url (or an url which is not pointing to your application).

$resp = $this->getResponse('redirectUrl');

The single property of this response is url, where you indicate the url to redirect.

$resp->url = "https://jelix.org";
return $resp;

There is shortcut method on controllers: redirectUrl($url)

return $this->redirectUrl("https://jelix.org");

Temporary or permanent redirection

By default, redirections are temporary redirection (http status code: 303). If you want to indicate a permanent redirection, you have to set the property $temporary to false.

$resp->temporary = false;

Or for methods redirectUrl() and redirect(), add an extra parameter false.