HttpCondition to match request URL to regex?

Splash Forums Rewrite Users HttpCondition to match request URL to regex?

This topic contains 2 replies, has 2 voices, and was last updated by  Headwinds 2 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26082

    Headwinds
    Participant

    In PrettyFaces, I had a line in my config file like this:

    <rewrite match="[a-z][0-9]+" outbound="false" processor="com.example.MyProcessor" />

    I’m trying to do a similar thing with Rewrite, but I can’t figure out how to test whether the request URL matches an arbitrary regex. I can subclass HttpCondition to do it myself, but I feel like I must be overlooking a built-in method? I’d like to be able to do something like this:

    builder.addRule()
        .when(RequestUrl.matches("[a-z][0-9]+"))
        .perform(...);

    I’m using Rewrite 2.0.11 and JSF 2.

    • This topic was modified 2 years, 3 months ago by  Headwinds.
    #26085

    You can do something like this:

    builder.addRule()
        .when(Path.matches("{something}"))
        .perform(...)
        .where("something").matches("[a-z][0-9]+");
    

    Have a look at:

    http://ocpsoft.org/rewrite/docs/configuration/parameters

    #26086

    Headwinds
    Participant

    Thanks very much!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.