rewrite: preserve non-canonical path encoding after uri replace (#7907)