No, redir simply maps a path to a redirect URL. (0.9 adds an if keyword you can use, but I’m not sure it supports whether files exist. @abiosoft could confirm, maybe get inspired… ;))
Thanks! Been using Caddy along with Laravel Valet. Works great!
It doesn’t look like redir will work in this case. If rewrite allowed external destinations I would be able to pull this off. This would be useful when working on a website locally and you don’t want to pull GBs of images. Or if you are migrating a website to a different location and need time to move uploads from one location to another without impacting user experience with missing images.
On another note, think I found a working solution using without on proxy. (Which by the way has a missing description in the docs).
rewrite /wp-content/uploads/ {
ext .jpg
to {path} {path}/ /rewrite/{uri}
}
proxy /rewrite/ example.com {
without /rewrite
}
And it is described in the docs, as prefix is a variable/placeholder value, which has a description of what the actual value should be:
prefix is a URL prefix to trim before proxying the request upstream. A request to /api/foo without /api, for example, will result in a proxy request to /foo.