Error code redirect

Updated at:

When an HTTP request returns a specific HTTP status code, you can configure an error code redirect rule to automatically redirect the request to a custom URL. This allows you to serve branded error pages to your visitors or route traffic to a maintenance announcement page.

Overview

During website operations, you often encounter the following scenarios:

  • Custom branded 404 pages: Serving a branded 404 page with custom navigation, instead of the default error message, when a user requests a nonexistent resource.

  • Maintenance announcements: Redirecting 503 and other server errors to a maintenance page during system maintenance to inform users of the expected recovery time.

  • Error handling service integration: Redirecting 5xx server-side errors to a dedicated error handling page to display consistent failure information and contact methods.

The error code redirect feature in Edge Security Accelerator (ESA) issues a 302 redirect to a configured redirect URL when the origin server returns a specific HTTP status code. With error code redirect, you can:

  • Improve the user experience by serving error pages that feature your brand's design and content.

  • Redirect error responses to a custom page, maintenance notice, or error handling service.

  • Apply rules to specific traffic by using custom match expressions.

How it works

When a visitor's request triggers a configured error code, ESA performs the following actions:

  1. The request is sent to the origin server.

  2. If the response status code matches an error code in an enabled rule, the system intercepts the response.

  3. ESA returns a 302 redirect to the URL specified in the rule.

Supported error codes

Error code redirect supports the following HTTP status codes:

Status code

Description

400

Bad Request

403

Forbidden

404

Not Found

405

Method Not Allowed

414

URI Too Long

416

Range Not Satisfiable

500

Internal Server Error

501

Not Implemented

502

Bad Gateway

503

Service Unavailable

504

Gateway Timeout

Limitations

  • Each rule supports up to 11 error code redirect entries—one entry per supported status code.

  • The redirect URL must be a complete URL that starts with http:// or https://.

  • Error code redirect rules and request redirect rules share the same quota. The quota shown on the page reflects the combined limit for both rule types.

  • Rules are matched from top to bottom. The first matching rule is applied, and subsequent rules are not evaluated.

  • Within a single rule, each status code can appear only once.

Procedure

  1. In the ESA console, select Websites, and in the Website column, click the target website.

  2. In the left navigation pane, choose Rules > Redirect Rules.

  3. On the Error Code Redirect tab, click Create Rule.

  4. On the Add Error Code Redirect Rule page, configure the following settings and click OK:

    • Rule Name: Enter a custom name for the rule, such as my-rule.

    • Apply to: Set the request characteristics to match, such as Hostname Equals www.example.com.

      You can also edit the expression directly, for example, (http.host eq "www.example.com").
    • Error Code Redirect: Click Add to add an error code mapping. For each entry:

      • Error Code: From the drop-down list, select an HTTP status code.

      • Redirect URL: Enter the full destination URL. The URL must start with http:// or https://. Example: https://www.example.com/error-pages/404.html.

Verify the rule

After you create the rule, follow these steps to verify that it works:

  1. Use the curl command to send a test request that triggers a configured error code. For example, request a non-existent resource to trigger a 404 error:

    curl -I http://www.example.com/nonexistent-page
  2. Check the response. A 302 status code is expected, and the Location header points to the configured custom URL:

    HTTP/1.1 302 Found
    Location: https://www.example.com/error-pages/404.html        
  3. Follow the redirect to confirm that the custom error page loads correctly:

    curl -vL http://www.example.com/nonexistent-page           

FAQ

Rule scope

The rule applies only to error codes returned by the origin server.

Multiple matching rules

Rules are evaluated from top to bottom. The first matching rule is applied, and evaluation stops. Place more specific rules above more general ones.

Shared rule quota

Yes. The two rule types share the same redirect rule quota. The quota shown on the Redirect Rules page reflects the combined count of the two rule types.