mirror of
https://github.com/caddyserver/website.git
synced 2025-04-24 22:16:15 -04:00
Finish documenting Caddy 2.8.0 features (#419)
This commit is contained in:
parent
6ac5539ef9
commit
af347e9623
17 changed files with 481 additions and 113 deletions
|
@ -18,23 +18,56 @@ uri [<matcher>] strip_prefix <target>
|
|||
uri [<matcher>] strip_suffix <target>
|
||||
uri [<matcher>] replace <target> <replacement> [<limit>]
|
||||
uri [<matcher>] path_regexp <target> <replacement>
|
||||
uri [<matcher>] query [-|+]<param> [<value>]
|
||||
uri [<matcher>] query {
|
||||
<param> [<value>] [<replacement>]
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
- The first (non-matcher) argument specifies the operation:
|
||||
The first (non-matcher) argument specifies the operation:
|
||||
|
||||
- **strip_prefix** strips the prefix from the path.
|
||||
- **strip_prefix** strips the prefix from the path.
|
||||
|
||||
- **strip_suffix** strips the suffix from the path.
|
||||
- **strip_suffix** strips the suffix from the path.
|
||||
|
||||
- **replace** performs a substring replacement across the whole URI.
|
||||
- **replace** performs a substring replacement across the whole URI.
|
||||
|
||||
- **path_regexp** performs a regular expression replacement on the path portion of the URI.
|
||||
- **<target>** is the prefix, suffix, or search string/regular expression. If a prefix, the leading forward slash may be omitted, since paths always start with a forward slash.
|
||||
|
||||
- **<target>** is the prefix, suffix, or search string/regular expression. If a prefix, the leading forward slash may be omitted, since paths always start with a forward slash.
|
||||
- **<replacement>** is the replacement string. Supports using capture groups with `$name` or `${name}` syntax, or with a number for the index, such as `$1`. See the [Go documentation](https://golang.org/pkg/regexp/#Regexp.Expand) for details. If the replacement value is `""`, then the matching text is removed from the value.
|
||||
|
||||
- **<replacement>** is the replacement string (only valid with `replace` and `path_regexp`). Supports using capture groups with `$name` or `${name}` syntax, or with a number for the index, such as `$1`. See the [Go documentation](https://golang.org/pkg/regexp/#Regexp.Expand) for details.
|
||||
- **<limit>** is an optional limit to the maximum number of replacements.
|
||||
|
||||
- **<limit>** is an optional limit to the maximum number of replacements (only valid with `replace`).
|
||||
- **path_regexp** performs a regular expression replacement on the path portion of the URI.
|
||||
|
||||
- **<target>** is the prefix, suffix, or search string/regular expression. If a prefix, the leading forward slash may be omitted, since paths always start with a forward slash.
|
||||
|
||||
- **<replacement>** is the replacement string. Supports using capture groups with `$name` or `${name}` syntax, or with a number for the index, such as `$1`. See the [Go documentation](https://golang.org/pkg/regexp/#Regexp.Expand) for details. If the replacement value is `""`, then the matching text is removed from the value.
|
||||
|
||||
- **query** performs manipulations on the URI query, with the mode depending on the prefix to the parameter name or the count of arguments. A block can be used to specify multiple operations at once, grouped and performed in this order: rename 🡒 set 🡒 append 🡒 replace 🡒 delete.
|
||||
|
||||
- With no prefix, the parameter is set with the given value in the query.
|
||||
|
||||
For example, `uri query foo bar` will set the value of the `foo` param to `bar`.
|
||||
|
||||
- Prefix with `-` to remove the parameter from the query.
|
||||
|
||||
For example, `uri query -foo` will delete the `foo` parameter from the query.
|
||||
|
||||
- Prefix with `+` to append a parameter to the query, with the given value. This will _not_ overwrite an existing parameter with the same name (omit the `+` to overwrite).
|
||||
|
||||
For example, `uri query +foo bar` will append `foo=bar` to the query.
|
||||
|
||||
- A param with `>` as an infix will rename the parameter to the value after the `>`.
|
||||
|
||||
For example, `uri query foo>bar` will rename the `foo` parameter to `bar`.
|
||||
|
||||
- With three arguments, query value regular expression replacement is performed, where the first arg is the query param name, the second is the search value, and the third is the replacement. The first arg (param name) may be `*` to perform the replacement on all query params.
|
||||
|
||||
Supports using capture groups with `$name` or `${name}` syntax, or with a number for the index, such as `$1`. See the [Go documentation](https://golang.org/pkg/regexp/#Regexp.Expand) for details. If the replacement value is `""`, then the matching text is removed from the value.
|
||||
|
||||
For example, `uri query foo ^(ba)r $1z` would replace the value of the `foo` param, where the value began with `bar` resulting in the value becoming `baz`.
|
||||
|
||||
URI mutations occur on the normalized or unescaped form of the URI. However, escape sequences can be used in the prefix or suffix patterns to match only those literal escapes at those positions in the request path. For example, `uri strip_prefix /a/b` will rewrite both `/a/b/c` and `/a%2Fb/c` to `/c`; and `uri strip_prefix /a%2Fb` will rewrite `/a%2Fb/c` to `/c`, but won't match `/a/b/c`.
|
||||
|
||||
|
@ -74,3 +107,44 @@ Collapse all repeated slashes in the request path (but not the request query) to
|
|||
```caddy-d
|
||||
uri path_regexp /{2,} /
|
||||
```
|
||||
|
||||
Set the value of the `foo` query parameter to `bar`:
|
||||
|
||||
```caddy-d
|
||||
uri query foo bar
|
||||
```
|
||||
|
||||
Remove the `foo` parameter from the query:
|
||||
|
||||
```caddy-d
|
||||
uri query -foo
|
||||
```
|
||||
|
||||
Rename the `foo` query parameter to `bar`:
|
||||
|
||||
```caddy-d
|
||||
uri query foo>bar
|
||||
```
|
||||
|
||||
Append the `bar` parameter to the query:
|
||||
|
||||
```caddy-d
|
||||
uri query +foo bar
|
||||
```
|
||||
|
||||
Replace the value of the `foo` query parameter where the value begins with `bar` with `baz`:
|
||||
|
||||
```caddy-d
|
||||
uri query foo ^(ba)r $1z
|
||||
```
|
||||
|
||||
Perform multiple query operations at once:
|
||||
|
||||
```caddy-d
|
||||
uri query {
|
||||
+foo bar
|
||||
-baz
|
||||
qux test
|
||||
renamethis>renamed
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue