Rewrite directive with chinese characters respond 404

Ah, I see. So the problem is that the {uri} placeholder returns the URI in its encoded form. So when the rewrite happens, encodes it a second time.

URI handling and encoding is very very tricky stuff.

In your case, I’m not convinced you even need the rewrite though.

You’re using handle_path, which strips the /Upload part of the URL. If you instead use handle, then it doesn’t strip it.

	handle /Upload/* {
		reverse_proxy http://cgs-server.mcs:3030
   	}

An alternate approach to doing the rewrite which I think won’t double-encode is using uri replace like this:

uri replace / /prefix 1

This should replace the first / in the URI with /prefix, limited to 1 match so it doesn’t replace every / in the URI.

1 Like