| title | Azure API Management policy reference - redirect-content-urls | Microsoft Docs |
|---|---|
| description | Reference for the redirect-content-urls policy available for use in Azure API Management. Provides policy usage, settings, and examples. |
| services | api-management |
| author | dlepow |
| ms.service | azure-api-management |
| ms.topic | reference |
| ms.date | 07/23/2024 |
| ms.author | danlep |
[!INCLUDE api-management-availability-all-tiers]
The redirect-content-urls policy rewrites (masks) links in the response body. Use in the outbound section to rewrite response body links to the backend service to make them point to the gateway instead. For example, you might do this to hide URLs of the original backend service when they appear in the response. Use in the inbound section for an opposite effect.
Note
This policy does not change any header values such as Location headers. To change header values, use the set-header policy.
[!INCLUDE api-management-policy-generic-alert]
<redirect-content-urls />- Policy sections: inbound, outbound
- Policy scopes: global, workspace, product, API, operation
- Gateways: classic, v2, consumption, self-hosted, workspace
- This policy can only be used once in a policy section.
<redirect-content-urls />For example, consider the following image, which shows an API response body that includes the original backend service URLs.
:::image type="content" source="media/redirect-content-urls-policy/original-response.png" alt-text="Screenshot showing original outbound response in test console in the portal.":::
After the redirect-content-urls policy is configured in the outbound section, the response body is rewritten to point to the gateway, in this case, https://apim-hello-world.azure-api.net.
:::image type="content" source="media/redirect-content-urls-policy/test-replaced-url.png" alt-text="Screenshot showing replaced URLs in test console in the portal.":::
[!INCLUDE api-management-policy-ref-next-steps]