How to use redir change uri

i want to redir /foo/bar to /foos/bar
i try redir /foo/* /foos/ but it will redir all /foo/bar to /foos, emmm,but i need redir to /foos/bar

and i use uri replace /foo/ /foos/ to resolve this,but i more want to send a 302 or 301 to client.

is there another way? thakns!

such as redir replace /foo/ /foos/ 302

Use a path_regexp matcher to capture just the part you want to keep, then use a placeholder when writing the target location.

Next time, please fill out the help topic template, as per the forum rules.

1 Like

thanks,I’ll try it :smile:

there is my Caddyfile, it works! {
	tls email
	encode zstd gzip
	root * /var/www/html/public
	log {
		output file /var/www/logs/access.log

    @pathmatch { 
        path_regexp path (^/post/)(.*)
    redir @pathmatch /posts/{re.path.2} 302
    #uri replace /post/ /posts/

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