When a client requests a Web service through a browser, the website hosting server returns the default 404 Not Found page if the requested URL does not exist. However, you may dislike the way the default 404 Not Found page looks. To improve user experience, you can associate full URLs with error codes that are carried in HTTP or HTTPS responses. When an error occurs, the server returns the associated custom page. This topic describes how to customize an error page.

Background information

Alibaba Cloud Content Delivery Network (CDN) provides two types of error pages: default page and custom page. Status code 404 is used as an example to describe the differences between the default page and custom page.
  • Default page: When the HTTP response carries a 404 error code, the server returns the default 404 Not Found page.
  • Custom page: When the HTTP response carries a 404 error code, the server returns the custom page. You must specify a full URL for the custom page.
Note
  • Default pages are considered Alibaba Cloud public resources and are free of charge.
  • Custom pages are considered personal resources and are charged.
When the Web server returns an HTTP 404 status code, the Web page is automatically redirected to the 404 Not Found page. Visitors may fail to access a URL if the URL generation rules of the Web page change, the file on the Web page is renamed or relocated, or a spelling error exists in the URL. When the Web server receives such a request, it returns a 404 status code to inform the visitor that the requested resource does not exist. Possible causes for a 404 error:
  • The website cannot be accessed through the requested port.
  • The Web service extension lockdown policy blocks this request.
  • The MIME map policy blocks this request.
Note When only one resource is requested and the resource is not found on the origin server, a 404 status code is returned and a 404 error page is displayed. When multiple resources are requested and only some of the resources are not found on the origin server, the 404 error page is not displayed.

Procedure

  1. Log on to the Alibaba Cloud CDN console.
  2. In the left-side navigation pane, click Domain Names.
  3. On the Domain Names page, find the target domain name and click Manage.
  4. In the left-side navigation pane of the specified domain, click Cache.
  5. Click Custom Pages.
  6. On the Custom Pages tab, click Customize.
    Customize Page dialog box
  7. In the Customize Page dialog box, set the parameters.
    For example, you want to store the error404.html page for the 404 error together with other static files to the origin and return this error page to requests addressed to the CDN domain exp.aliyun.com. Then, you only need to select 404 from the Error Code drop-down list and enter the full URL http://exp.aliyun.com/error404.html into the Link field.
  8. Click OK.

    After the custom page is created, you can click Modify or Delete in the Actions column to modify or delete the custom page.