netqyq
(Yongqiang)
1
How to redirect a path like following?
redirect from /db/*
to /db/mongodb/*
.
Why path_regexp
is unrecognized?
1. Caddy version (caddy version
):
v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=
2. How I run Caddy:
My Caddyfile
abc.com {
root * /root/webroot
file_server
encode gzip
path_regexp mongodb (^m.*mongo.*\/$)
redir /dt/{re.mongo.1} /dt/mongodb/{re.mongo.1}
}
a. System environment:
Ubuntu 20.04.1 (no docker)
b. Command:
./caddy reload
2022/02/09 05:26:03.194 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: Caddyfile:33: unrecognized directive: path_regexp```
matt
(Matt Holt)
2
netqyq
(Yongqiang)
3
My need is that redirect from /db/*
to /db/mongodb/*
,
but I don’t know how to do it.
redir <matcher> to
As Matt said, you’re not using the correct syntax to define a named matcher. Please review the docs he linked.
Your regexp is also incorrect. You probably want something like this:
@mongo path_regexp mongo ^/db/(.*)
rewrite @mongo /db/mongodb/{re.mongo.1}
2 Likes
matt
(Matt Holt)
6
Thanks Francis; I was mobile so typing out the whole solution would have been a bit tedious. So I’m glad you did!
2 Likes
system
(system)
Closed
7
This topic was automatically closed after 30 days. New replies are no longer allowed.