1. Packages
  2. Packages
  3. Cloudflare Provider
  4. API Docs
  5. PageRule
Viewing docs for Cloudflare v6.15.0
published on Saturday, May 2, 2026 by Pulumi
cloudflare logo
Viewing docs for Cloudflare v6.15.0
published on Saturday, May 2, 2026 by Pulumi

    Accepted Permissions

    • Access: Apps and Policies Read
    • Access: Apps and Policies Revoke
    • Access: Apps and Policies Write
    • Access: Mutual TLS Certificates Write
    • Access: Organizations, Identity Providers, and Groups Write
    • Analytics Read
    • Apps Write
    • Cache Purge
    • DNS Read
    • DNS Write
    • Firewall Services Read
    • Firewall Services Write
    • Load Balancers Read
    • Load Balancers Write
    • Logs Read
    • Logs Write
    • Page Rules Read
    • Page Rules Write
    • SSL and Certificates Read
    • SSL and Certificates Write
    • Stream Read
    • Stream Write
    • Trust and Safety Read
    • Trust and Safety Write
    • Workers Routes Read
    • Workers Routes Write
    • Workers Scripts Read
    • Workers Scripts Write
    • Zaraz Admin
    • Zaraz Edit
    • Zaraz Read
    • Zero Trust: PII Read
    • Zone Read
    • Zone Settings Read
    • Zone Settings Write
    • Zone Write

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const examplePageRule = new cloudflare.PageRule("example_page_rule", {
        zoneId: "023e105f4ecef8ad9ca31a8372d0c353",
        target: "example.com/*",
        priority: 1,
        status: "active",
        actions: {
            forwardingUrl: {
                url: "https://example.com/foo",
                statusCode: 301,
            },
        },
    });
    
    import pulumi
    import pulumi_cloudflare as cloudflare
    
    example_page_rule = cloudflare.PageRule("example_page_rule",
        zone_id="023e105f4ecef8ad9ca31a8372d0c353",
        target="example.com/*",
        priority=1,
        status="active",
        actions={
            "forwarding_url": {
                "url": "https://example.com/foo",
                "status_code": 301,
            },
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-cloudflare/sdk/v6/go/cloudflare"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := cloudflare.NewPageRule(ctx, "example_page_rule", &cloudflare.PageRuleArgs{
    			ZoneId:   pulumi.String("023e105f4ecef8ad9ca31a8372d0c353"),
    			Target:   pulumi.String("example.com/*"),
    			Priority: pulumi.Int(1),
    			Status:   pulumi.String("active"),
    			Actions: &cloudflare.PageRuleActionsArgs{
    				ForwardingUrl: &cloudflare.PageRuleActionsForwardingUrlArgs{
    					Url:        pulumi.String("https://example.com/foo"),
    					StatusCode: pulumi.Int(301),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var examplePageRule = new Cloudflare.Index.PageRule("example_page_rule", new()
        {
            ZoneId = "023e105f4ecef8ad9ca31a8372d0c353",
            Target = "example.com/*",
            Priority = 1,
            Status = "active",
            Actions = new Cloudflare.Inputs.PageRuleActionsArgs
            {
                ForwardingUrl = new Cloudflare.Inputs.PageRuleActionsForwardingUrlArgs
                {
                    Url = "https://example.com/foo",
                    StatusCode = 301,
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.PageRule;
    import com.pulumi.cloudflare.PageRuleArgs;
    import com.pulumi.cloudflare.inputs.PageRuleActionsArgs;
    import com.pulumi.cloudflare.inputs.PageRuleActionsForwardingUrlArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var examplePageRule = new PageRule("examplePageRule", PageRuleArgs.builder()
                .zoneId("023e105f4ecef8ad9ca31a8372d0c353")
                .target("example.com/*")
                .priority(1)
                .status("active")
                .actions(PageRuleActionsArgs.builder()
                    .forwardingUrl(PageRuleActionsForwardingUrlArgs.builder()
                        .url("https://example.com/foo")
                        .statusCode(301)
                        .build())
                    .build())
                .build());
    
        }
    }
    
    resources:
      examplePageRule:
        type: cloudflare:PageRule
        name: example_page_rule
        properties:
          zoneId: 023e105f4ecef8ad9ca31a8372d0c353
          target: example.com/*
          priority: 1
          status: active
          actions:
            forwardingUrl:
              url: https://example.com/foo
              statusCode: 301
    

    Create PageRule Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new PageRule(name: string, args: PageRuleArgs, opts?: CustomResourceOptions);
    @overload
    def PageRule(resource_name: str,
                 args: PageRuleArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def PageRule(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 actions: Optional[PageRuleActionsArgs] = None,
                 target: Optional[str] = None,
                 priority: Optional[int] = None,
                 status: Optional[str] = None,
                 zone_id: Optional[str] = None)
    func NewPageRule(ctx *Context, name string, args PageRuleArgs, opts ...ResourceOption) (*PageRule, error)
    public PageRule(string name, PageRuleArgs args, CustomResourceOptions? opts = null)
    public PageRule(String name, PageRuleArgs args)
    public PageRule(String name, PageRuleArgs args, CustomResourceOptions options)
    
    type: cloudflare:PageRule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args PageRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args PageRuleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args PageRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PageRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PageRuleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    PageRule Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The PageRule resource accepts the following input properties:

    Actions PageRuleActions
    Target string
    Priority int
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    Status string
    The status of the Page Rule. Available values: "active", "disabled".
    ZoneId string
    Identifier.
    Actions PageRuleActionsArgs
    Target string
    Priority int
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    Status string
    The status of the Page Rule. Available values: "active", "disabled".
    ZoneId string
    Identifier.
    actions PageRuleActions
    target String
    priority Integer
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status String
    The status of the Page Rule. Available values: "active", "disabled".
    zoneId String
    Identifier.
    actions PageRuleActions
    target string
    priority number
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status string
    The status of the Page Rule. Available values: "active", "disabled".
    zoneId string
    Identifier.
    actions PageRuleActionsArgs
    target str
    priority int
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status str
    The status of the Page Rule. Available values: "active", "disabled".
    zone_id str
    Identifier.
    actions Property Map
    target String
    priority Number
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status String
    The status of the Page Rule. Available values: "active", "disabled".
    zoneId String
    Identifier.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the PageRule resource produces the following output properties:

    CreatedOn string
    The timestamp of when the Page Rule was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    ModifiedOn string
    The timestamp of when the Page Rule was last modified.
    CreatedOn string
    The timestamp of when the Page Rule was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    ModifiedOn string
    The timestamp of when the Page Rule was last modified.
    createdOn String
    The timestamp of when the Page Rule was created.
    id String
    The provider-assigned unique ID for this managed resource.
    modifiedOn String
    The timestamp of when the Page Rule was last modified.
    createdOn string
    The timestamp of when the Page Rule was created.
    id string
    The provider-assigned unique ID for this managed resource.
    modifiedOn string
    The timestamp of when the Page Rule was last modified.
    created_on str
    The timestamp of when the Page Rule was created.
    id str
    The provider-assigned unique ID for this managed resource.
    modified_on str
    The timestamp of when the Page Rule was last modified.
    createdOn String
    The timestamp of when the Page Rule was created.
    id String
    The provider-assigned unique ID for this managed resource.
    modifiedOn String
    The timestamp of when the Page Rule was last modified.

    Look up Existing PageRule Resource

    Get an existing PageRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: PageRuleState, opts?: CustomResourceOptions): PageRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            actions: Optional[PageRuleActionsArgs] = None,
            created_on: Optional[str] = None,
            modified_on: Optional[str] = None,
            priority: Optional[int] = None,
            status: Optional[str] = None,
            target: Optional[str] = None,
            zone_id: Optional[str] = None) -> PageRule
    func GetPageRule(ctx *Context, name string, id IDInput, state *PageRuleState, opts ...ResourceOption) (*PageRule, error)
    public static PageRule Get(string name, Input<string> id, PageRuleState? state, CustomResourceOptions? opts = null)
    public static PageRule get(String name, Output<String> id, PageRuleState state, CustomResourceOptions options)
    resources:  _:    type: cloudflare:PageRule    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Actions PageRuleActions
    CreatedOn string
    The timestamp of when the Page Rule was created.
    ModifiedOn string
    The timestamp of when the Page Rule was last modified.
    Priority int
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    Status string
    The status of the Page Rule. Available values: "active", "disabled".
    Target string
    ZoneId string
    Identifier.
    Actions PageRuleActionsArgs
    CreatedOn string
    The timestamp of when the Page Rule was created.
    ModifiedOn string
    The timestamp of when the Page Rule was last modified.
    Priority int
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    Status string
    The status of the Page Rule. Available values: "active", "disabled".
    Target string
    ZoneId string
    Identifier.
    actions PageRuleActions
    createdOn String
    The timestamp of when the Page Rule was created.
    modifiedOn String
    The timestamp of when the Page Rule was last modified.
    priority Integer
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status String
    The status of the Page Rule. Available values: "active", "disabled".
    target String
    zoneId String
    Identifier.
    actions PageRuleActions
    createdOn string
    The timestamp of when the Page Rule was created.
    modifiedOn string
    The timestamp of when the Page Rule was last modified.
    priority number
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status string
    The status of the Page Rule. Available values: "active", "disabled".
    target string
    zoneId string
    Identifier.
    actions PageRuleActionsArgs
    created_on str
    The timestamp of when the Page Rule was created.
    modified_on str
    The timestamp of when the Page Rule was last modified.
    priority int
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status str
    The status of the Page Rule. Available values: "active", "disabled".
    target str
    zone_id str
    Identifier.
    actions Property Map
    createdOn String
    The timestamp of when the Page Rule was created.
    modifiedOn String
    The timestamp of when the Page Rule was last modified.
    priority Number
    The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
    status String
    The status of the Page Rule. Available values: "active", "disabled".
    target String
    zoneId String
    Identifier.

    Supporting Types

    PageRuleActions, PageRuleActionsArgs

    alwaysUseHttps boolean
    automaticHttpsRewrites string
    browserCacheTtl number
    browserCheck string
    bypassCacheOnCookie string
    cacheByDeviceType string
    cacheDeceptionArmor string
    cacheKeyFields PageRuleActionsCacheKeyFields
    cacheLevel string
    cacheOnCookie string
    cacheTtlByStatus {[key: string]: string}
    disableApps boolean
    disablePerformance boolean
    disableSecurity boolean
    disableZaraz boolean
    edgeCacheTtl number
    emailObfuscation string
    explicitCacheControl string
    forwardingUrl PageRuleActionsForwardingUrl
    hostHeaderOverride string
    ipGeolocation string
    mirage string
    opportunisticEncryption string
    originErrorPagePassThru string
    polish string
    resolveOverride string
    respectStrongEtag string
    responseBuffering string
    rocketLoader string
    securityLevel string
    sortQueryStringForCache string
    ssl string
    trueClientIpHeader string
    waf string

    PageRuleActionsCacheKeyFields, PageRuleActionsCacheKeyFieldsArgs

    PageRuleActionsCacheKeyFieldsCookie, PageRuleActionsCacheKeyFieldsCookieArgs

    CheckPresences List<string>
    Includes List<string>
    CheckPresences []string
    Includes []string
    checkPresences List<String>
    includes List<String>
    checkPresences string[]
    includes string[]
    check_presences Sequence[str]
    includes Sequence[str]
    checkPresences List<String>
    includes List<String>

    PageRuleActionsCacheKeyFieldsHeader, PageRuleActionsCacheKeyFieldsHeaderArgs

    CheckPresences List<string>
    Excludes List<string>
    Includes List<string>
    CheckPresences []string
    Excludes []string
    Includes []string
    checkPresences List<String>
    excludes List<String>
    includes List<String>
    checkPresences string[]
    excludes string[]
    includes string[]
    check_presences Sequence[str]
    excludes Sequence[str]
    includes Sequence[str]
    checkPresences List<String>
    excludes List<String>
    includes List<String>

    PageRuleActionsCacheKeyFieldsHost, PageRuleActionsCacheKeyFieldsHostArgs

    resolved Boolean
    resolved boolean
    resolved Boolean

    PageRuleActionsCacheKeyFieldsQueryString, PageRuleActionsCacheKeyFieldsQueryStringArgs

    Excludes List<string>
    Includes List<string>
    Excludes []string
    Includes []string
    excludes List<String>
    includes List<String>
    excludes string[]
    includes string[]
    excludes Sequence[str]
    includes Sequence[str]
    excludes List<String>
    includes List<String>

    PageRuleActionsCacheKeyFieldsUser, PageRuleActionsCacheKeyFieldsUserArgs

    DeviceType bool
    Geo bool
    Lang bool
    DeviceType bool
    Geo bool
    Lang bool
    deviceType Boolean
    geo Boolean
    lang Boolean
    deviceType boolean
    geo boolean
    lang boolean
    device_type bool
    geo bool
    lang bool
    deviceType Boolean
    geo Boolean
    lang Boolean

    PageRuleActionsForwardingUrl, PageRuleActionsForwardingUrlArgs

    StatusCode int
    Url string
    StatusCode int
    Url string
    statusCode Integer
    url String
    statusCode number
    url string
    statusCode Number
    url String

    Import

    $ pulumi import cloudflare:index/pageRule:PageRule example '<zone_id>/<pagerule_id>'
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Viewing docs for Cloudflare v6.15.0
    published on Saturday, May 2, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.