Fix EZP-23364

You can move this to the `needsCaseRedirect()` by adding `$pathPrefix` as new parameter to it and so avoid the repetitions below.