Updated on 2025-08-12 GMT+08:00

Adding a Content Replacement Rule

Scenario

A content replacement rule allows for interface content substitution based on the key name.

For example, if you want to replace the content Yang xx in the demo API with Zhang San, you can use a content replacement rule.

This topic describes how to create a content replacement rule.

Procedure

  1. Log in to the web console of the API data security protection system as the sysadmin user.
  2. In the navigation pane, choose Security Policies > Content Replace.
  3. On the Content Replace page, click Add and set content replacement rule parameters. For the description of parameters, see Parameters for adding a content replacement rule.

    Figure 1 Configuring a content replacement rule
    Table 1 Parameters for adding a content replacement rule

    Parameter

    Description

    Rule name

    Name of a customized content replacement rule.

    Description

    Enter the rule description.

    Service name

    Select an application to which the rule applies from the drop-down list.

    Endpoint URL

    Select and configure interface matching conditions. If multiple interfaces are entered, separate them with line breaks. The rule is triggered when one of the interfaces is matched.

    Replacement rules

    Set the parameters of the replacement rule.
    • Location: Select the location of the content to be replaced.
    • Key: Enter the key name of the content to be replaced.
    • Replace type: Select a matching mode, which can be keyword or regular expression.
    • Source: Enter the original content to be replaced.
    • Target: Enter the content after replacement.

    File type

    Select the file type to which the rule applies, including json, html, js, and xml.

  4. Click OK.

Operation Result

After the rule is added and enabled, you can use a proxy to access the application and view the replacement content.

Related Operations

On the Content Replace page, you can also perform the following operations:

  • Modifying a rule: Locate the target rule and click Edit on the right.
  • Deleting a rule: Locate the target rule and click Delete on the right.
  • Deleting rules in batches: Select multiple rules and click Delete in the upper right corner.