Go to page content

redirect

Redirect to another page.

This action redirects the browser to another page or back to the previous page.

Example:

{% button title="home" action={redirect location="/"} %}

Redirects back to the home page when the button is clicked.

Back in history example:

{% button title="Back" action={redirect back} %}

After clicking the button the browser will go back to the last page using the Javascript history.

Example of using dispatch rules for the redirect location:

{% button title="edit" action={redirect dispatch="admin_edit_rsc" id=my_id} %}

When clicked the browser is redirected to the admin edit page for the resource with the id of “my_id”.

This action can have the following arguments:

ArgumentDescriptionExample
backWhen given then the browser is directed to the previous page.back
dispatchThe name of a dispatch rule.  All other parameters are assumed to be parameters for the dispatch rule.dispatch="admin"
idWhen back and dispatch are not defined then the redirect uri will be the page_url of the resource.id=42
locationThe http address to redirect to. Can be an url with or without host name.location="http://example.com"

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.