Caddy2 reverse_proxy Change status 302 Location in Response Head

handle_path /mypath/* {
	reverse_proxy http://www.test.com {
		header_up Host {upstream_hostport}
		header_up X-Real-IP {remote_host}
		header_up X-Forwarded-Port {server_port}
                    @redirect status 302
                    handle_response @redirect {
                      header Location /mypath{rp.header.Loaction}
                    }
	}
}

How should I modify the path of the Location header for the 302 redirect proxy?

So this is a custom error page?

handle_path /mypath/* {
	reverse_proxy http://www.test.com {
		header_up Host {upstream_hostport}
		header_up X-Real-IP {remote_host}
		header_up X-Forwarded-Port {server_port}
		
		@redirect status 302
		handle_response @redirect {
			root * /path/to/error/pages
			rewrite * /{rp.status_code}.html
			file_server
		}
	}
}

If you have more than one error page, you could add more status codes after 302.