Redirect to subdomain, partial different URI

1. Caddy version (caddy version):


2. How I run Caddy:


a. System environment:

Debian 10

b. Command:

systemctl start caddy

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

Paste config here, replacing this text.
Use `caddy fmt` to make it readable.
DO NOT REDACT anything except credentials.
Make sure the backticks stay on their own lines.

3. The problem I’m having:

I can’t redirect or rewrite uri to subdomain

origin link:

need to rewrite or redirect to:

Please help me how to get it works.
Thank you.

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

Use a path_regexp matcher to capture the part of the URL you want to keep, then you can use the regexp matches when writing the target URL. {
	@oldUrl path_regexp old /category/test/(.*)
	redir @oldUrl{re.old.1}

You can play around with (pick the Golang flavor) to play with the regexp to get it to do what you want.


Great. It works with your config.
Thanks so much.


This topic was automatically closed after 30 days. New replies are no longer allowed.