Replicate redirect URL building logic for post requests