Need to remove a string from the URL

Using v1 Caddy. I need to remove a string from a url.

app.mydomain.com/api/v3/search?apikey=xxxxx

The version of the app I’m running is not v3 so I need to complete remove v3/ from the url so the result is

app.mydomain.com/api/search?apikey=xxxxx

Lot’s of posts out there describe how to remove trailing strings, but I’m not sure how to remove strings in the middle of the url.

If you use Caddy v2, this can be done really easily:

uri_replace /api/v3/search /v3/ /

uri_replace docs

  • First argument is the matcher token, so, that exact path /api/v3/search in this case
  • Second arg is the substring to find
  • Third arg is the replacement
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.