Skip to content

How to redirect to another page

macourtney edited this page Sep 13, 2010 · 3 revisions

Added for version: 0.4
Updated for version: 0.7

To redirect to another action and controller use the redirect-to function in your controller.

Example:

If you want to redirect the browser to ‘http://www.google.com/’, use the following code in the action function of the action you want to redirect from.

(redirect-to "http://www.google.com/")

If you want to redirect to a specific directory (likely a static page) on the current server use:

(redirect-to "/static/page.html")

If you want to redirect to another action, say index, in the same controller use:

(redirect-to { :action "index" })

If you want to redirect to another action, say index, in another controller, home, use:

(redirect-to { :controller "home", :action "index" })

If you want to add the parameter :id with value 2:

(redirect-to { :params { :id 2 } })
Clone this wiki locally