If the URI in a request does not match the URI of the requested resource on the origin server, Alibaba Cloud CDN can overwrite the request URI by using the URI of the resource. Then, the request can be redirected to the actual URI.
Background information
The HTTP 302 status code, also known as the Found message, indicates that the requested resource has temporarily relocated. After you add a URI rewrite rule, Alibaba Cloud CDN edge nodes can add the new URI of the resource to the Location header in the HTTP 302 response message. After the client receives the message, the client sends a request to the new URI.
After you add a URI rewrite rule, the edge nodes return the HTTP 302 status code to clients if the requested resource has relocated. You can also set the HTTP status code to 303 or 307. To change the HTTP status code,submit a ticket.
HTTP status code | Description | Processing method | Use scenario |
---|---|---|---|
302 | Found | GET requests remain unchanged. Requests that use other request methods may be changed to GET. | A web page is temporarily inaccessible due to unknown reasons. In this case, search engines do not update the URL to the web page. |
303 | See Other | GET requests remain unchanged. Requests that use other request methods are changed to GET. The message body is dropped. | Redirect PUT and POST requests to prevent frequent redirections that are caused by a page refresh. |
307 | Temporary Redirect | Both the request method and message body remain unchanged. | A web page is temporarily inaccessible due to unknown reasons. In this case, search engines do not update the URL to the web page. If the website supports requests that use request methods other than GET, the HTTP 307 status code is returned instead of the HTTP 302 status code. |
Scenario
A resource on the origin server is moved to a different URL, and the URL of the resource that is cached on the edge nodes is updated. However, a client sends a request to the original URL. In this case, Alibaba Cloud CDN must rewrite the request to redirect the request to the new URL. For example, an image file is moved from the /download/ directory to the /image/ directory.

Procedure
Configuration examples

When a client sends a request to http://example.aliyundoc.com/hello
, the request contains /hello
. After the CDN edge node receives the HTTP 302 status code, the node adds the new
URI http://example.aliyundoc.com/index.html
to the Location header and returns it to the client. Then, the client sends a request
to the received URI http://example.aliyundoc.com/index.html
.