redirect()
Twig Function
The redirect()
function redirects the response to a URL or theme page.
To perform a redirect, pass the first argument as the destination, as either a CMS page name or a URL address.
{% if record.notFound %}
{% do redirect('404') %}
{% endif %}
Page parameters can be passed as the second argument.
{% do redirect('docs', { slug: 'home' }) %}
To redirect to a URL pass the fully qualified address instead of the page name.
{% do redirect('https://octobercms.com') %}
To include a redirect code, such as 302
(temporary) or 301
(permanent), use the second or third argument. The default is code 302
.
{% do redirect('https://octobercms.com', 301) %}
← response() collect() →