Does map handler support using the capture groups in destination?
map * {host} {my_folder} {
~(.+)\.localhost \\1
default "fail"
}
Does map handler support using the capture groups in destination?
map * {host} {my_folder} {
~(.+)\.localhost \\1
default "fail"
}
Good question. If it did, it would look more like {re.my_folder.1}
, but I don’t think these end up being named regexp. /cc @matt
But for your use-case, if you only have those two cases, I recommend using a named matcher with header_regexp
instead:
Maybe something like this:
@myfolder header_regexp folder Host (.+)\.localhost
handle @myfolder {
root * /var/www/{re.folder.1}
}
handle {
root * /var/www/fail
}
The map handler doesn’t set placeholders like this, but it could, someone can contribute that functionality. Would be pretty similar to what’s in the regexp matchers.
Thank you @francislavoie and @matt
I will file a feature request issue.
EDIT: done - Feature request: map handler takes account of regex capture group · Issue #3971 · caddyserver/caddy · GitHub
This topic was automatically closed after 30 days. New replies are no longer allowed.