Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Cloud CDN
    • Overview
    • Points of presence
    • Resource
    • Origins and origin groups
    • Request redirect
    • Content caching
    • Secure tokens
    • IP-based access policy
    • Dedicated IP addressing
    • Location rules
    • Log export
    • Labels
    • Quotas and limits
  • Access management
  • Pricing policy
  • Terraform reference
  • Metrics Monitoring
  • Request logs
  • Audit Trails events
  • Release notes
  • Troubleshooting

In this article:

  • Rewrite rule
  • Flag
  • Use cases
  1. Concepts
  2. Request redirect

Request redirection

Written by
Yandex Cloud
Updated at July 9, 2026
View in Markdown
  • Rewrite rule
  • Flag
  • Use cases

You can customize redirection of requests from a CDN resource to an origin by changing the URI of the request using a Rewrite rule.

For example, you can use this option to reconfigure content request paths if the file and folder structure of the origin has changed. You can also use redirection if you want to keep search engine rankings of your content when moving your resource to a new address.

You can enable request redirection for a CDN resource using the management console, CLI, or API.

To configure request redirection, you need to set a rewrite rule and specify a flag.

Rewrite ruleRewrite rule

A rewrite rule must contain two space-separated directives:

  • Source path: URI part to replace. It is specified as a regular expression.

    Regular expression parts can be placed in brackets. In this case, the URI parts mapped to such expression parts will be available in the edited path in the values of the $1, $2, ... $9 variables, where the variable number matches the sequence number of the regular expression part in the source path.

  • Edited path: URI part that must replace the original path matching the specified regular expression.

    In the edited path, you can use variables containing parts of the source path which have been placed in brackets: $1, $2, ... $9.

Rewrite rule example:

/(videos)/(events)/(\d{4}-\d{2}-\d{2})/(.*) /$2/$1/$3-$4

This rule will modify the request URI as follows:

Source URI: https://example.com/videos/events/2024-01-01/new-year.avi
Target URI: https://example.com/events/videos/2024-01-01-new-year.avi

FlagFlag

Flags allow you to stop further processing of Rewrite directives or return redirect to the user. The following flags are available for Rewrite rules:

  • break: Terminates the processing of the current set of directives.
  • last: Terminates the processing of the current set of directives and starts searching for a new CDN server that matches the new URI.
  • redirect: Returns a temporary redirect with the 302 status code to the user. This flag is used if the replacement string does not start with http://, https://, or $scheme.
  • permanent: Returns a permanent redirect with the 301 status code to the user.

Use casesUse cases

  • Enabling a blue-green and canary deployment of web service versions
  • Migrating to Yandex Cloud CDN from a third-party CDN provider

Useful linksUseful links

  • Guide for enabling request redirection

Was the article helpful?

Previous
Hiding of origin headers
Next
Content caching
© 2026 Direct Cursus Technology L.L.C.