Specification: isredirect

isredirect Element

Redirect the browser to a specified URL.

Syntax

<isredirect
  location="${target_url}"
  permanent="true"
>

location

Required

Allowed data type: string or expression.

target_url specifies a target URL used by the browser to send a new request.

permanent

false is the default

Allowed data type: string or expression.

  • true causes the system to generate an HTTP 301 response code.
  • false causes system to generate an HTTP 302 response code.

Note If the permanent attribute isn't provided, false is the default.

Purpose

Note <isredirect> appears before <iscache> in templates, because it clears the response created up to that point.

Example

The following example checks whether the buyer has enabled cookies in their browser or not. Depending on the result, the browser is redirected.

<isif condition="${request.httpCookies['UserID']}">
  <isredirect location="${URLUtils.url('LoginPanel-Start')}" permanent="false">
<iselse>
  <!--- cookies are not enabled --->
</isif>

Some browsers don't support redirect from HTTP to HTTPS. In such a case use the HTML meta tag "refresh", for example:

<html>
  <head>
    <meta http-equiv="refresh" content="0; URL='${URLUtils.url(...)}'">