docs: Add path_regexp option for uri directive (#144)

ad8d01cb66
This commit is contained in:
Francis Lavoie 2021-04-16 13:36:54 -04:00 committed by GitHub
parent 371993227e
commit b0324a9470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.
- **&lt;target&gt;** 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.
- **&lt;replacement&gt;** is the replacement string (only valid with `replace`).
- **&lt;replacement&gt;** is the replacement string (only valid with `replace` and `path_regexp`).
- **&lt;limit&gt;** 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,} /
```