# Redirect Handle From Origin

**Redirect Handle From Origin** allows the CDN to modify request or response headers when the origin returns a **3xx redirect**.

You can select which redirect codes to handle and optionally add or modify headers sent during redirection.

This provides greater control over origin-driven redirects and ensures consistent client behavior.

You can manage Redirect Handle From Origin using the [Medianova Control Panel](https://cloud.medianova.com) or the [API](https://clients.medianova.com/api-documentation/performance-cdn/origin-settings#put-api-v1-cdn-organization_uuid-resource-resource_uuid-4).

In the Medianova Control Panel, go to **CDN Resources**, select your resource, and navigate to **Origin Settings**

## Redirect Handle From Origin

Follow the steps below to enable and configure redirect handling for your CDN Resource.

{% stepper %}
{% step %}
**Enable Redirect Handling**

Toggle **Status** to **On**.

<figure><img src="https://542970813-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtK7oIwmhUHdEJcaH4Hx8%2Fuploads%2F6z0Xo6eqblU3IlKK7BCv%2FEkran%20Resmi%202024-12-11%2013.27.59.png?alt=media&#x26;token=ccacf346-9387-41ea-aa75-e918a1997be0" alt="" width="563"><figcaption></figcaption></figure>

Additional configuration options become active.
{% endstep %}

{% step %}
**Select Redirect Codes to Handle**

Open **Handle Origin Redirection Error** and choose one or more redirect status codes that the CDN should process.

These codes determine **which 3xx responses from your origin will trigger redirect handling logic**. When a selected code is returned by the origin, the CDN applies your configured header settings and processes the redirect instead of simply passing it through unchanged.

Supported redirect codes:

* **301** — Permanent redirect
* **302** — Temporary redirect
* **303** — See Other
* **307** — Temporary redirect (method is preserved)
* **308** — Permanent redirect (method is preserved)

The CDN will apply your redirect-handling configuration **only** to the selected status codes, giving you granular control over how different redirect types are processed.
{% endstep %}

{% step %}
**Configure Request Headers (Optional)**

Enter a **Request Header Key** and **Request Header Value** if you want to include or modify request headers when a redirect occurs.

Examples:

* `Request Header Key`: `User-Agent`
* `Request Header Value`: `Custom-UA`

If you do not need to change request headers, leave these fields empty.
{% endstep %}

{% step %}
**Add Custom Headers (Optional)**

Use **Add Header Key** and **Add Header Value** to specify additional headers that should be appended during redirect handling.

Examples:

* `Add Header Key`: `X-Debug-Redirect`
* `Add Header Value`: `true`

These headers are included in redirected requests or responses depending on your configuration.
{% endstep %}

{% step %}
**Save the Configuration**

Select **Add** to register your header definitions.\
Then click **Submit** to apply the Redirect Handle From Origin settings.\
Redirect handling is now active for your CDN Resource.
{% endstep %}
{% endstepper %}

### **Redirect Handling Logic**

When the origin returns a selected **3xx** status code:

1. CDN intercepts the response.
2. CDN adds or modifies headers based on your configuration.
3. The redirect is returned to the client with the updated headers.

### **Header Processing**

* **Request Header Key / Value** modifies the header sent from CDN → Origin.
* **Add Header Key / Value** appends additional headers in redirection processing.

### **Status Toggle**

* When **On**, CDN evaluates redirect codes and applies your header settings.
* When **Off**, CDN forwards redirect responses without modification.

## **Troubleshooting**

**Issue:** Redirect handling does not apply.\
**Cause:** Status toggle is disabled or no redirect codes are selected.\
**Fix:** Enable **Status** and choose at least one code under **Handle Origin Redirection Error**.

**Issue:** Headers are not appearing in redirected responses.\
**Cause:** Header Key or Value fields are empty.\
**Fix:** Ensure both fields are filled before selecting **Add**.

**Issue:** Redirect behavior is inconsistent.\
**Cause:** Origin and CDN redirect configurations conflict.\
**Fix:** Review origin redirect rules and ensure the CDN's configured headers do not override necessary behavior.
