Cloudflare 中文文档
Terraform
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Add exceptions with Page Rules

In the Configure HTTPS settings tutorial, you configured zone settings that apply to all incoming requests for example.com. In this tutorial, you will add an exception to these settings using Page Rules.

Specifically, you will increase the security level for a URL known to be expensive to render and cannot be cached: https://www.example.com/expensive-db-call. Additionally, you will add a redirect from the previous URL used to host this page.

​​ 1. Create a new branch and append the page rule

Create a new branch and append the configuration.

​​ 2. Preview and merge the changes

Preview the changes Terraform will make and then merge them into the master branch.

​​ 3. Apply and verify the changes

First, test request the (now missing) old location of the expensive-to-render page.

As expected, the location cannot be found. Apply the Page Rules, including the redirect that should fix this error.

With the Page Rules in place, try that call again, along with a test for the I’m Under Attack mode:

The call works as expected. In the first case, the Cloudflare global network responds with a 301 redirecting the browser to the new location. In the second case, the Cloudflare global network initially responds with a 503, which is consistent with the I’m Under Attack mode.