Redirect()

Redirect the browser to a specified address.

Syntax 

1Redirect(1,2)

Function Properties 

OrdinalTypeDescription
1StringRequired. The address to direct the user’s browser to.
2BooleanRequired. Indicates whether the redirect is temporary or permanent. A value of true results in an HTTP 301 Moved Permanently redirect. A value of false results in a 302 Found redirect.

Usage 

To use this function, provide the destination address, and indicate whether the redirect is temporary or permanent. This example redirects the user to https://www.example.com.

1<script runat="server">
2  Platform.Load("Core", "1");
3  Redirect("https://www.example.com", false);
4</script>

If you include a try/catch block in your SSJS code, and the try block contains a redirect, it triggers the catch block. In this code example, the try block contains a redirect to https://salesforce.com. However, the result is a redirection to https://example.com.

1<script runat="server">
2  Platform.Load("Core", "1");
3  try {
4    Redirect("https://salesforce.com", false);
5  } catch(e) {
6    Redirect("https://example.com", false);
7  }
8</script>