Redirect with changed uri

I’m trying to find a way to redirect with changing uri on the fly.

It’s easy task:
301 redirect to

hanlde_path and uri doesn’t help because they don’t redirect.
If use usual redirect than it gets uri and the result is:

Sorry if it already was questioned but I didn’t find clear answer about right way to do it.

You’ll want a path_regexp matcher here probably. {
	@old path_regexp old ^/old/(.*)
	redir @old{re.old.1}{query} 301

Yep, it works. Thank you!

One small question — what is {re. Is it cut from ‘regexp’? Didn’t find it in the documentation

It’s a placeholder shortcut available in the Caddyfile. re is short for “regular expression”

1 Like

Thanx! Very useful!

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