---
schema_version: "1"
id: 95fab0d9d32c5e1ed4bcf9ece27c305ae3dc9b1e006cd2d85210cb33a887a008
title: getRedirectCode()
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_System_PageReference_getRedirectCode.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getRedirectCode.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: bdf9d89fbed90e09aa28a8621419c0f5ce33c8f77415b8ea9d96cddd7de8900e
description: Returns the HTTP redirect code used when getRedirect() is set to true for the PageReference object.
---
# getRedirectCode()

Returns the HTTP redirect code used when [getRedirect()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getRedirect.htm "Returns the current value of the PageReference object's redirect attribute.") is set to true for the PageReference object.

## Signature

public Integer getRedirectCode()

## Return Value

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

Possible Values:

- 0 — Redirect using the default redirect action for this PageReference. Typically a JavaScript-based redirection or HTTP 302.
    
    ![Note](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note.png)
    
    #### Note
    
    [Site URLRewriter Interface](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_site_urlRewriter.htm "HTML (New Window)") implementations pointing to a PageReference with a redirectCode of 0 are not redirected.
- 301 — Moved Permanently. Redirect users by sending an HTTP GET request to the target location. Includes instructions to update any references to the requested URL with the target location.
- 302 — Moved Temporarily. Redirect users by sending an HTTP GET request to the target location. Because the redirection is temporary, it doesn’t include update instructions.
- 303 — See Other. Redirect users by sending an HTTP GET request to the target location. Not commonly used. Useful when the client sends a POST request and you want the client to call the new web page using a GET request instead of a POST request.
- 307 — Temporary Redirect. Send the same HTTP request, regardless of the HTTP method, to the target location. Because the redirection is temporary, it doesn’t include update instructions.
- 308 — Permanent Redirect. Send the same HTTP request, regardless of the HTTP method, to the target location. Includes instructions to update any references to the requested URL with the target location.