mirror of
https://github.com/caddyserver/website.git
synced 2025-04-21 20:46:15 -04:00
docs: General updates for beta 18
This commit is contained in:
parent
ca8197d483
commit
6f712d4ee4
11 changed files with 114 additions and 118 deletions
47
src/docs/markdown/caddyfile/directives/uri.md
Normal file
47
src/docs/markdown/caddyfile/directives/uri.md
Normal file
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
title: uri (Caddyfile directive)
|
||||
---
|
||||
|
||||
# uri
|
||||
|
||||
Manipulates a request's URI. It can strip path prefix/suffix or replace substrings on the whole URI.
|
||||
|
||||
This directive is distinct from [`rewrite`](rewrite) in that `uri` _partially_ changes the URI, rather than setting it to something completely different as `rewrite` does. While `rewrite` is treated specially as an internal redirect, `uri` is just another handler.
|
||||
|
||||
|
||||
## Syntax
|
||||
|
||||
```
|
||||
uri [<matcher>] strip_prefix|strip_suffix|replace \
|
||||
<target> \
|
||||
[<replacement> [<limit>]]
|
||||
```
|
||||
|
||||
- The first (non-matcher) argument specifies the operation:
|
||||
- **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.
|
||||
- **<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`).
|
||||
- **<limit>** is an optional limit to the maximum number of replacements (only valid with `replace`).
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
Strip `api/` from the beginning of all request paths:
|
||||
|
||||
```
|
||||
uri strip_prefix api/
|
||||
```
|
||||
|
||||
Strip `.php` from the end of all request paths:
|
||||
|
||||
```
|
||||
uri strip_suffix .php
|
||||
```
|
||||
|
||||
Replace "/docs/" with "/v1/docs/" in any request URI:
|
||||
|
||||
```
|
||||
uri replace /docs/ /v1/docs/
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue