Everyone comes across situations, when you have a broken link on your site, the server could not find what was requested or the server is temporarily unavailable. Usually the user gets an internal error message from the server in these situations. However, these messages aren’t that helpful in many situations. The user would want to know more or may need more assistance regarding what the user was looking for. In these situations a well-designed page can just do the trick.

A well designed page can have multiple components. These components can be easily configured on NetScaler and sent to clients without any backend server communication.

NetScaler enables to serve rich HTML error pages without any backend server communication. You can customize your error page using data URI scheme to embed images and serve rich HTML content, using default policy expressions.

This blog focuses on how using Rewrite or Responder feature on NetScaler you can send back such responses.

STEP1: Configuring the policy expression – “page_error_expression”

Use Case 1: Embed Image

As we can’t embed the image object directly in the policies or host the object itself on the NetScaler. We will use data URI scheme to embed images in default expressions so that NetScaler can produce the same image on the error pages. The data URI scheme is a URI scheme that provides a way to include data in-line in web pages as if they were external resources.

Now, to embed the desired image, follow the mentioned steps:

Step a: Pick the image you want to embed.

Step b: Convert the image to base64 code by using following binary to base64 convertor:


Step c: Write a Rich HTML code with the embedded image base64 code, in the policy expression:

Note: The HTML content you add in the policy expression has to be separated with “+” after every 255 bytes. We need to do this, as it’s the max length of the literal strings that can be used in an expression. This is done to complete the required long string we have to concatenate.

This html content will result into a page with the Citrix logo image embedded like this.

Figure 1. This is the page, the HTML code represents in the policy expression.

Use Case 2: Embed components like, text, search engine or a website link.

Step a: Adding a Rich HTML page in the policy expression.

In this use case, we have embedded the HTML code for a couple of text strings, a search engine and a website link.

This is to showcase that you can write any desired rich HTML code using policy expressions to get customized error pages.

Figure 2. This is the page, the HTML code represents in the policy expression.

Now the story just doesn’t end here. After you have the desired policy expression configured. You need to do the following steps:

STEP2: Configuring the rewrite action – “page_error_action”

Add rewrite action page_error_action REPLACE_HTTP_RES page_error_expression

With this we create a “page_error_action” rewrite action which replaces the HTTP response with the configured “page_error_expression” policy expression.

STEP3: Configuring the rewrite policy – “page_error_policy”

Add rewrite policy page_error_policy “HTTP.RES.STATUS.EQ(404)” page_error_action

Here, we create a page_error_policy” rewrite policy, which checks if the HTTP response status is equivalent to 404. It hits the page_error_action” rewrite action if the policy returns TRUE.

STEP4: Binding the rewrite policy – “page_error_policy” globally

Bind rewrite global page_error_policy 100 END -type RES_DEFAULT

Here, we bind the page_error_policy” globallywith 100 as the priority and type as RES_DEFAULT.

With these simple four steps you can easily customize the error pages using data URI scheme or simple rich HTML code in the policy expressions.