mirror of
https://github.com/caddyserver/website.git
synced 2025-04-22 04:56:17 -04:00
parent
371993227e
commit
b0324a9470
1 changed files with 9 additions and 2 deletions
|
@ -12,7 +12,7 @@ This directive is distinct from [`rewrite`](rewrite) in that `uri` _partially_ c
|
|||
## Syntax
|
||||
|
||||
```caddy-d
|
||||
uri [<matcher>] strip_prefix|strip_suffix|replace \
|
||||
uri [<matcher>] strip_prefix|strip_suffix|replace|path_regexp \
|
||||
<target> \
|
||||
[<replacement> [<limit>]]
|
||||
```
|
||||
|
@ -21,8 +21,9 @@ uri [<matcher>] strip_prefix|strip_suffix|replace \
|
|||
- **strip_prefix** strips a prefix from the path, if it has the prefix.
|
||||
- **strip_suffix** strips a suffix from the path, if it has the suffix.
|
||||
- **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.
|
||||
- **<replacement>** is the replacement string (only valid with `replace`).
|
||||
- **<replacement>** is the replacement string (only valid with `replace` and `path_regexp`).
|
||||
- **<limit>** is an optional limit to the maximum number of replacements (only valid with `replace`).
|
||||
|
||||
|
||||
|
@ -45,3 +46,9 @@ Replace "/docs/" with "/v1/docs/" in any request URI:
|
|||
```caddy-d
|
||||
uri replace /docs/ /v1/docs/
|
||||
```
|
||||
|
||||
Collapse all repeated slashes in the request path (but not the request query) to a single slash:
|
||||
|
||||
```caddy-d
|
||||
uri path_regexp /{2,} /
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue