This document contains information for an outdated version and may not be maintained any more. If some of your projects still use this version, consider upgrading as soon as possible.
Controllers can facilitate redirecting users from one place to another using
HTTP redirection using the
$this->redirect('goherenow'); // redirect to Page::goherenow(), i.e on the contact-us page this will redirect to /contact-us/goherenow/ $this->redirect('goherenow/'); // redirect to the URL on yoursite.com/goherenow/. (note the trailing slash) $this->redirect('http://google.com'); // redirect to http://google.com $this->redirectBack(); // go back to the previous page.
redirect() method takes an optional HTTP status code, either
301 for permanent redirects, or
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 '~'
private static $url_handlers = array( 'players/john' => '~>coach' );
For more information on
$url_handlers see the Routing documenation.