Reply To: Ignore JSF resources

Splash Forums Rewrite Users Ignore JSF resources Reply To: Ignore JSF resources

#26255

Hey! The best way I’ve found to do this is to make sure you use the Resource.exists() condition, you can also use the ServletMapping.includes(). For instance:

/*
                * Block direct file access.
                */
               .addRule()
               .when(DispatchType.isRequest().and(Direction.isInbound())
                        .and(Path.matches("/{p}.xhtml"))
                        .and(Resource.exists("/{p}.xhtml"))
                        .andNot(ServletMapping.includes("/{p}")))
               .perform(SendStatus.error(404))
               .where("p").matches(".*")

               /*
                * Application Routes
                */
               .addRule(Join.path("/{p}/").to("/faces/{p}/index.xhtml").withChaining())
               .when(Resource.exists("/{p}/index.xhtml"))
               .where("p").matches(".*")

               .addRule(Join.path("/{p}").to("/faces/{p}.xhtml").withChaining())
               .when(Resource.exists("/{p}.xhtml"))
               .where("p").matches(".*")