> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1894.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up a CDN resource to follow origin redirects

Redirection from Origin is a CDN resource option that controls how the CDN handles HTTP 3xx redirect responses from the origin.

## About redirection from origin

The Redirection from Origin option controls whether the CDN follows redirects returned by the origin. By default, this option is disabled, which means that when the origin returns an HTTP 3xx status code, the CDN caches and serves this response to the end user. When the option is enabled, the CDN automatically retrieves the target content from the new location, which is then cached and returned to the end user.

<Warning>Enabling or disabling this option may cause users to receive an outdated version of the content. [Purge the cache](/cdn/clear-cdn-resource-cache-by-url-pattern-or-all) after making changes.</Warning>

## Configuration

Configure origin redirection via the Customer Portal or REST API.

<Tabs>
  <Tab title="Customer Portal">
    To configure origin redirection using the [Gcore Customer Portal](https://portal.gcore.com/cdn/resources/list):

    1\. Navigate to **CDN** and select the CDN resource to configure.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/p8h1t4ovqAJ5zxbi/images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/cdn-resources-list.png?fit=max&auto=format&n=p8h1t4ovqAJ5zxbi&q=85&s=35d8feb64e4c1ab3e74835d411b40cdd" alt="CDN resources list" width="1400" height="900" data-path="images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/cdn-resources-list.png" />
    </Frame>

    2\. In the sidebar, under the **Cache** section, select **Redirection from origin**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/p8h1t4ovqAJ5zxbi/images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/cdn-resource-settings-cache.png?fit=max&auto=format&n=p8h1t4ovqAJ5zxbi&q=85&s=4e3ed22e63ac53ce2b73699323b9b83d" alt="CDN resource settings with Cache section open" width="1400" height="900" data-path="images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/cdn-resource-settings-cache.png" />
    </Frame>

    3\. Toggle **Follow redirect from origin** on.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/p8h1t4ovqAJ5zxbi/images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/follow-redirect-enabled.png?fit=max&auto=format&n=p8h1t4ovqAJ5zxbi&q=85&s=e9307d61a04aa74e883dd953de9e732e" alt="Follow redirect from origin toggle enabled with status codes field" width="1400" height="900" data-path="images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/follow-redirect-enabled.png" />
    </Frame>

    4\. Select one or more status codes in the **Choose redirect status codes** field. The options are:

    * 301 — to follow redirect for status code HTTP 301
    * 302 — selected by default; follows redirect for status code HTTP 302
    * 303 — to follow redirect for status code HTTP 303
    * 307 — to follow redirect for status code HTTP 307
    * 308 — to follow redirect for status code HTTP 308

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/p8h1t4ovqAJ5zxbi/images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/redirect-status-codes-dropdown.png?fit=max&auto=format&n=p8h1t4ovqAJ5zxbi&q=85&s=e9e5a1b1cfd043ec82606578e193575c" alt="Choose redirect status codes dropdown" width="1400" height="900" data-path="images/docs/cdn/cdn-resource-options/cache/set-up-a-cdn-resource-to-follow-origin-redirects/redirect-status-codes-dropdown.png" />
    </Frame>

    5\. Click **Save changes**. Allow at least 15 minutes for the changes to take effect.

    <Info>After saving, [purge the cache](/cdn/clear-cdn-resource-cache-by-url-pattern-or-all) so that end users receive updated content.</Info>
  </Tab>

  <Tab title="REST API">
    To configure origin redirection using the API, include the `follow_origin_redirect` object in the request body. The following is a sample code for the object:

    ```
    "options": {  
      "follow_origin_redirect": {  
        "enabled": true,  
        "codes": [  
          302,  
          308  
        ]  
      }  
    }
    ```

    **Request properties**

    The `follow_origin_redirect` object passes the following information:

    | **Property** | **Description**                                                                                                                                                                                                 |
    | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | enabled      | This property indicates whether to enable Redirection from Origin.<br />Possible values:<br /> - true enables the option<br /> - false disables the option                                                      |
    | codes        | This property is an array of HTTP status codes that will cause the CDN to follow a redirect. The array must contain a minimum of one and a maximum of five items.<br />Possible values: 301, 302, 303, 307, 308 |

    **Example**

    This example shows a [CDN update request](/api-reference/cdn/cdn-resources/change-cdn-resource-1) that activates the Redirection from Origin and instructs the CDN to follow redirects for status codes 301, 302, and 303.

    ```json theme={null}
    PUT /cdn/resources/{id}
    {
      "options": {
        "follow_origin_redirect": {
          "enabled": true,
          "codes": [301, 302, 303]
        }
      }
    }
    ```
  </Tab>
</Tabs>
