Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,23 @@ This example lets you rewrite a request from `example.com/images` to `example.co

To create a rule:

1. In the Cloudflare dashboard, go to the **Account home** page.
1. In the Cloudflare dashboard, go to the **Rules Overview** page.

<DashButton url="/?to=/:account/home" />
<DashButton url="/?to=/:account/:zone/rules/overview" />

2. Select your domain.
3. Go to **Rules** > **Overview**.
4. Next to **URL Rewrite Rules**, select **Create rule**.
5. Under **If incoming requests match**, select **Wildcard pattern** and enter the following **Request URL** (update with your own domain):
2. Next to **URL Rewrite Rules**, select **Create rule**.
3. Under **If incoming requests match**, select **Wildcard pattern** and enter the following **Request URL** (update with your own domain):

```txt
https://example.com/images/*
```

6. Under **Then rewrite the path and/or query** > **Path**, enter the following values (using your account hash):
4. Under **Then rewrite the path and/or query** > **Path**, enter the following values (using your account hash):

- **Target path**: [`/`] `images/*`
- **Rewrite to**: [`/`] `cdn-cgi/imagedelivery/<ACCOUNT_HASH>/${1}`

7. Select **Deploy** when you are done.
5. Select **Deploy** when you are done.

### Advanced version

Expand All @@ -68,17 +66,15 @@ This example lets you rewrite a request from `example.com/images/some-image-id/w

To create a rule:

1. In the Cloudflare dashboard, go to the **Account home** page.
1. In the Cloudflare dashboard, go to the **Rules Overview** page.

<DashButton url="/?to=/:account/home" />
<DashButton url="/?to=/:account/:zone/rules/overview" />

2. Select your domain.
3. Go to **Rules** > **Overview**.
4. Next to **URL Rewrite Rules**, select **Create rule**.
5. Under **If incoming requests match**, select **Custom filter expression** and then select **Edit expression**.
6. In the text field, enter `(http.request.uri.path matches "^/images/.*$")`.
7. Under **Path**, select **Rewrite to**.
8. Select _Dynamic_ and enter the following in the text field.
2. Next to **URL Rewrite Rules**, select **Create rule**.
3. Under **If incoming requests match**, select **Custom filter expression** and then select **Edit expression**.
4. In the text field, enter `(http.request.uri.path matches "^/images/.*$")`.
5. Under **Path**, select **Rewrite to**.
6. Select _Dynamic_ and enter the following in the text field.

```txt
regex_replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ This page covers examples for the following scenarios:
- Transform every image requested on your zone with Images

To create a rule:
1. In the Cloudflare dashboard, go to the **Account home** page.
1. In the Cloudflare dashboard, go to the **Rules Overview** page.

<DashButton url="/?to=/:account/home" />
<DashButton url="/?to=/:account/:zone/rules/overview" />

2. Select your domain.
3. Go to **Rules** > **Overview**.
4. Select **Create rule** next to **URL Rewrite Rules**.
2. Select **Create rule** next to **URL Rewrite Rules**.

## Before you start

Expand Down