This document contains information about a future release and not the current stable version (4). Be aware that information on this page may change and API's may not be stable for production use.


Controllers can facilitate redirecting users from one place to another using HTTP redirection using the Location HTTP header.


// redirect to Page::goherenow(), i.e on the contact-us page this will redirect to /contact-us/goherenow/

// redirect to the URL on (note the trailing slash)

// redirect to

// go back to the previous page.

Status Codes

The redirect() method takes an optional HTTP status code, either 301 for permanent redirects, or 302 for temporary redirects (default).

$this->redirect('/', 302);
// go back to the homepage, don't cache that this page has moved

Redirection in URL Handling

Controllers can specify redirections in the $url_handlers property rather than defining a method by using the '~' operator.

private static $url_handlers = array(
    'players/john' => '~>coach'

For more information on $url_handlers see the Routing documenation.

API Documentation

Was this article helpful?