LPS-52274 Optimize rewrite rules and make UrlRewriteFilter switchable