Set Custom Error Page

Last update:2024-05-30 22:19:48

When users request content from the origin server, and there is a chance that the requested content does not exist or other errors occur, the origin server typically returns a default error message page, indicating that there is an issue with their request. These prompt pages, if not specially designated, are simple and monotonous. When users encounter similar request failure situations through the CDNetworks CDN platform while trying to access content from the origin server, you can easily specify a designated prompt page to be returned to the users on the CDNetworks CDN platform.

On the CDNetworks CDN platform, you can define multiple distinct page return rules for a domain by configuring such as requested file types and response status codes, enabling you to tailor responses to different user requests by delivering specific error message pages. For a given user request or response status code, different rules can specify unique return pages. By prioritizing the effectiveness of these rules and following the order of rule matching, you can ensure that the intended error message page is clearly displayed to the user.

How To Set Custom Error page

  1. Log in to the CDNetworks Console and select the appropriate product.
  2. Navigate to the Configuration, locate the domain you wish to configure, and click on Edit Configuration at the top or the Edit button to the right of the domain CDNetworks Supports Let's Encrypt Certificate.
  3. Upon accessing the modification page, navigate to the Page Rewriting/Redirection section and then select Error Page Redirection, click the +Add button.
  4. On the rule editing page, you can easily add the following configuration options based on your needs.

Effective Range

Options Descriptions
All Requests Indicates that all requests initiated towards the associated domain are applicable to this rule.
Only Homepage This rule is applicable only to requests in the root directory, e.g.,http://domain/or https://domain/.
Specified File Type This rule applies to the requests for specified file types, you can choose from listed ones or customize your file types in this field. Separate multiple file types with ;, e.g.,ace;aac.
Specified Directory This rule applies to all requests aimed at specified directories while directories must begin and end with a / and can be composed of any combination of letters, numbers, and certain special symbols (including underscores, hyphens, percentage signs, and dots), e.g.,/file/1%1/,indicates that the rule applies to requests for the directoryhttp://domain/file/1%1/and all files within it.
Please note that, you need to separate multiple directories with a line break.

Redirected Status Code
CDNetworks provides you with a readily accessible list of commonly used status codes. The current list of commonly used status codes is as follows:403;404;500;502;503;504.
In addition to selecting from the list, you can also enter the response status codes for which you wish to redirect pages in the input box. Separate multiple status codes with ;, e.g.,301;302.

Tips:
Please be aware that when multiple status codes are specified, the matching criterion operates on an ‘OR’ basis. This means that if the status code of a returned request matches any one of the specified status codes, then that request will be deemed applicable to this rule.

Redirected URL
You can input the URL of the error message page you wish to display to the user in this field. The URL must be complete and accessible. Each separate rule can only be configured with one URL, e.g.,http://domain/error.html.
Besides, you could also configure whether case sensitive for the configured URL by checking Yes or No.

Priority
In the Priority field, you could specify the priority level of this rule. Based on the user’s request, the system matches the rules you have set. If multiple rules apply, the rule with the higher priority will be applied first.

After you have completed setting the configurations, please click OK and then select Next to submit your settings. To minimize any potential disruptions to your production environment, we strongly recommend conducting a Pre-deploy test in a staging environment. This crucial step ensures that your configurations are accurate before they go live. Once you have verified the accuracy of the settings, click Deploy Now to implement them in the live environment. The configurations typically become effective within 3-5 minutes. For comprehensive guidance on pre-deployment testing and to verify the effectiveness of your configurations, please consult the tutorial Deploy the Configurations to Staging Environment for Validation.

Best Practices

Example 1:All requests with response status code 404
For all requests for domains which are linked to this rule, when a 404 status code is returned, the error page presented to the client will be specified as https://domain/files/error.html.

Example 2:Requests for PNG files with response status code 404
For all PNG files requests for domains which are linked to this rule, when a 404 status code is returned, the error page presented to the client will be specified as https://domain/files/error_PNG.html.

When a domain such as https://domain/ has both of the rules configured as described above, in the event that a user requests a file https://domain/hello.png which does not exist and a 404 status code is returned, the error page presented to the client will be https://domain/files/error_PNG.html due to the higher priority of rule in Example 2 over the one in Example 1.

Notes

The URL redirected to must be complete and accessible.
If the redirected URL is inaccessible, it might repeatedly trigger the error page redirection rule, potentially leading to a loop of redirections. Consequently, any cyclic redirection requests may be forcibly terminated by the CDNetworks CDN platform.

Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!