Page Rules - Content
This document describes using static files by enabling the ‘Content’ option in page rules.
This document describes using static files by enabling the “Content” option in page rules.
Configuration Description
| Parameter | Data Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Type of the file, can be ‘file’ or ‘dir’, representing file and directory respectively |
| file | string | No | Full path of the file or directory |
| ignore_uri_prefix_type | string | No | Only used when type is ‘dir’, used to ignore URI prefix when searching for static files, values can be ‘string’ or ‘regex’ |
| ignore_uri_prefix_value | string | No | Only used when type is ‘dir’, used to ignore URI prefix when searching for static files |
Configuration Example
- enable_rule: true
order: 8
conditions:
- var: uri
op: prefix
val: /file1
content:
type: file
file: dir1/setup.sh
- enable_rule: true
order: 9
conditions:
- var: uri
op: prefix
val: /oredge
content:
ignore_uri_prefix_type: string
ignore_uri_prefix_value: /oredge
type: dir
file: dir1
In the first page rule, when the request URI is /file1, it will directly return the content of the setup.sh file in the dir1 directory.
In the second page rule, when the prefix of the request URI is /oredge, it will search for static files in the dir1 directory based on the URI after /oredge. If found, it will directly return the file content; if not found, it will return a 404 status code. For example, /oredge/setup.sh will match the /dir1/setup.sh file.