From b0324a94706f46e24520ed9f9a66a6025a341b6d Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 16 Apr 2021 13:36:54 -0400 Subject: [PATCH] docs: Add `path_regexp` option for `uri` directive (#144) https://github.com/caddyserver/caddy/commit/ad8d01cb66316cf04ea49ec277316d6f83b9abb6 --- src/docs/markdown/caddyfile/directives/uri.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/docs/markdown/caddyfile/directives/uri.md b/src/docs/markdown/caddyfile/directives/uri.md index 71ae116..e414efc 100644 --- a/src/docs/markdown/caddyfile/directives/uri.md +++ b/src/docs/markdown/caddyfile/directives/uri.md @@ -12,7 +12,7 @@ This directive is distinct from [`rewrite`](rewrite) in that `uri` _partially_ c ## Syntax ```caddy-d -uri [] strip_prefix|strip_suffix|replace \ +uri [] strip_prefix|strip_suffix|replace|path_regexp \ \ [ []] ``` @@ -21,8 +21,9 @@ uri [] 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,} / +```