Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Access URL Rewrite

Updated on 2024-08-22 GMT+08:00

You can set access URL rewrite rules to redirect user requests to the URLs of cached content.

Scenarios

If the path for storing server resources changes, the path for storing resources on CDN PoPs changes accordingly. For example, the path of an image has changed from /test to /testnew. If a user sends a request to the original URL, CDN PoPs need to rewrite the requested URL.

If a URL rewrite rule has been configured, CDN matches URLs in redirection mode and uses the HTTP 302 status code (302 Found) to indicate that the requested resource has been temporarily moved to another location. Specifically, CDN PoPs add the new URL to the HTTP Location header in the 302 response to the client. After receiving the response, the client sends a request to the new URL. Table 1 lists the redirection status codes and their meanings.

Table 1 Redirection modes

Code

Meaning

Processing Method

Description

301

Moved Permanently

The GET method does not change. Other methods may change to the GET method.

The resource is moved permanently.

302

Found

The GET method does not change. Other methods may change to the GET method.

This page is temporarily unavailable for unforeseen reasons.

303

See Other

The GET method does not change. Other methods are changed to the GET method (the message body is lost).

Used to redirect after a PUT or a POST, so that refreshing the result page does not re-trigger the operation.

307

Temporary Redirect

Neither the method nor the message body changes.

This page is temporarily unavailable for unforeseen reasons. Better than 302 when non-GET operations are available on the site.

Procedure

  1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

    The CDN console is displayed.

  2. In the navigation pane, choose Domains.
  3. In the domain list, click the target domain name or click Configure in the Operation column.
  4. Click the Cache Settings tab.
  5. In the Access URL Rewrite area, click Add.
    Figure 1 Adding an access URL rewrite rule
    Table 2 Parameters

    Parameter

    Description

    Content Type

    • Directory: Execute the rule for files in the specified directory.
    • Full path: Execute the rule for the file under the specified path.
    • Home page: Execute the rule when the homepage of the domain name is visited.

    Content

    • When Content Type is set to Directory, enter up to 20 directories and separate them by commas (,). A directory starts with a slash (/). Wildcards (*) are not supported. Example: /test/folder01,/test/folder02
    • When Content Type is set to Full path, enter the path of a file or a path with wildcards (*). A path must start with a slash (/) and cannot end with a wildcard (*). Only one wildcard (*) can be entered. Examples: /test/index.html or /test/*.jpg
    • When Content Type is set to Home page, this parameter is left blank. You can configure only one rule for the homepage.
    • Regular expression match is not supported.

    Redirection URL

    Target URL. Start with a slash (/) and do not contain http://, https://, or the domain name. Example: /newtest/index.html

    • When Content Type is set to Full path, the wildcard (*) can be captured by $1. For example, if Content is set to /test/*.jpg and Redirection URL is set to /newtest/$1.jpg, when a user requests /test/11.jpg, $1 is replaced by 11, so the requested URL after redirection is /newtest/11.jpg.

    Action

    Select Redirect or Break.

    • Redirect: If the requested URL matches this rule, the request is redirected to the target URL. After this rule is executed, if other rules exist, CDN continues to execute these rules.
    • Break: If the requested URL matches this rule, the request is rewritten as the target URL. After this rule is executed, CDN does not execute any other rules and returns status code 200. You cannot set the redirection host or status code.

    Redirection Host

    Domain name to which client requests are redirected. Specify the value when Action is set to Redirect.

    • By default, the acceleration domain name is used.
    • The value contains 1 to 255 characters and starts with http:// or https://, for example, http://www.example.com.

    Redirection Status Code

    Specify the value when Action is set to Redirect. The status code can be 301, 302, 303, or 307. For details about their differences, see Table 1.

    Priority

    Priority of the rule. Enter an integer ranging from 1 to 100. A greater number indicates a higher priority.

    Each rule must have a unique priority.

  6. Click OK.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback