Cloudflare\Zone\Pagerules::update PHP Method

update() public method

Update a page rule [BETA] (permission needed: #zone:edit) Replace a page rule. The final rule will exactly match the data passed with this request.
public update ( string $zone_identifier, string $identifier, array $targets, array $actions, integer | null $priority = null, string | null $status = null )
$zone_identifier string API item identifier tag
$identifier string
$targets array Targets to evaluate on a request
$actions array The set of actions to perform if the targets of this rule match the request. Actions can redirect the url to another url or override settings (but not both)
$priority integer | null A number that indicates the preference for a page rule over another. In the case where you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a higher priority on the latter (#2) so it will override the first.
$status string | null Status of the page rule
    public function update($zone_identifier, $identifier, $targets, $actions, $priority = null, $status = null)
    {
        $data = ['targets' => $targets, 'actions' => $actions, 'priority' => $priority, 'status' => $status];
        return $this->put('zones/' . $zone_identifier . '/pagerules/' . $identifier, $data);
    }