Confirm that you are not using the agent model. Rewrite content rules aren't available for agent deployments.

A rewrite content rule uses a subset of the Java regular expression syntax that excludes look-behind constructs, such as \b, and the boundary matcher, \G. If no Java regular expression syntax is used, the rule performs a case-sensitive search and replace.

The most common use case for this rule is to rewrite host names within URLs contained in HTML, JavaScript, or CSS content.

Info:

Extensive use of rewrite content rules might have significant performance implications.

This rule supports content that is either chunked or streamed from the target server. When sent to the client, the content is always chunked.

To add a rewrite content rule:

  1. Click Access and then go to Rules > Rules.
  2. Click + Add Rule.
  3. In the Name field, enter a unique name up to 64 characters long.

    Special characters and spaces are allowed.

  4. In the Type list, select Rewrite Content.
  5. To define what type of response data to which the rewrite rule applies, enter one or more Response Content-Types.

    The default values are text/html, text/plain, and application/json. The list is an ordered list.

    Info:

    Only text-based content types are supported. Text-based content types compressed with gzip, deflate, or compress will decompress prior to rewrite rule processing, however, the content is not re-compressed before sending to the client.

  6. Define one or more sets of Find and Replace Criteria.

    If multiple criteria are specified, each operation is performed against the original content, effectively applying the rule concurrently.

    Important:

    Changes can affect CSS, Javascript, and other text-based elements served to the client. Be sure to properly craft the regular expression to avoid unintentionally modifying content.

  7. If the protected application does not return a Content-Type header, select Missing Content-Type Allowed.
  8. If you enable Missing Content-Type Allowed, specify the encoding the application returns in the Missing Content-Type Charset field.

    This field could contain UTF-8. A list of valid values is available in the Oracle Java 8 SE Technical Note.

  9. If necessary, increase the size of the buffer used to perform the replace operation by clicking Show Advanced and entering a value in Maximum Buffer Size.
    Note:

    Replacement values cannot be larger than the buffer size. The minimum buffer size you can specify is 1024 bytes. There is no maximum value.

  10. Click Save.