---
schema_version: "1"
id: 3e0901bf1dd9fe42745a5da55be3ee91b55f313314883d4cd3b02e73bc21ff27
title: setRedirect(redirect)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_System_PageReference_setRedirect.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setRedirect.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: abd609ed640d5ff2714efa660b5f50a41e4e967d8e3a910f798647397cd4b54f
description: Sets the value of the PageReference object's redirect attribute. If set to true, a redirect is performed through a client side redirect.
---
# setRedirect(redirect)

Sets the value of the PageReference object's redirect attribute. If set to true, a redirect is performed through a client side redirect.

## Signature

public System.PageReference setRedirect(Boolean redirect)

## Parameters

- **redirect**: Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

## Return Value

Type: [System.PageReference](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_system_pagereference.htm "A PageReference is a reference to an instantiation of a page. Among other attributes, PageReferences consist of a URL and a set of query parameter names and values.")

## Usage

This type of redirect performs an HTTP GET request, and flushes the view state, which uses POST. If set to false, the redirect is a server-side forward that preserves the view state if and only if the target page uses the same controller and contains the proper subset of extensions used by the source page.

Note that if the URL of the PageReference object is set to a website outside of the salesforce.com domain, or to a page with a different controller or controller extension, the redirect always occurs, regardless of whether the redirect attribute is set to true or false.