How can I do for it using rewrite

Splash Forums Rewrite Users How can I do for it using rewrite

This topic contains 8 replies, has 4 voices, and was last updated by  Kalpana 4 years, 11 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #18445

    yyq2009
    Participant

    I want use rewrite to finish this work, how can I do?

    <rule>

    <from>^/([w-]+).html(?*.*)$</from>

    <to>/$1.jsf$2</to>

    </rule>

    <outbound-rule>

    <from>^/([w-]+).jsf(?*.*)$</from>

    <to>$1.html$2</to>

    </outbound-rule>

    I want every page ends with .jsf to be shown ending with .html, and when request reached the server, it could be reversed.

    Thanks in advance.

    #22634

    You can implement something like this using a Join. Have a look at this integration test here:

    https://github.com/ocpsoft/rewrite/blob/master/impl-servlet/src/test/java/org/ocpsoft/rewrite/servlet/config/JoinConfigurationProvider.java

    So you could do something like this:

    .addRule( Join.path("/{name}.html").to("/{name}.jsf") );

    I hope this helps. :)

    Christian

    #22635

    yyq2009
    Participant

    Thanks for your reply.

    .addRule( Join.path("/{name}.html").to("/{name}.jsf") );

    I hava a question. Does the rule or Join rule do two things?

    first : Convert url /article.html?id=1 to /article.jsf?id=1 when client request, and then jsf lifecycle can process it

    second : If server redirect to login.jsf?expired=true, and it will rewrite to client as login.html?expired=true

    Thanks.

    #22636

    Short answer: yes! :)

    Long answer: A Join is actually a combination of two rules. An inbound rule which forwards incoming requests to the rewritten “internal” URL. And an outbound rule which rewrites URL generated by the server (redirects, URLs written to the response, etc.) to the externally visible URL.

    #22637

    yyq2009
    Participant

    Thanks, it’s very clear! and I suggest you add this to examples of rewrite, then users can understand Join rule better.

    Where I can get the doc of user guide about it?

    I don’t know if Join rule can work with regex expression, Could it?

    #22638

    Satan
    Participant

    .addRule( Join.path(“/{name}.html”).to(“/{name}.jsf”).where(“name”).matchs(“[a-zA-Z]+”) );

    #22639

    @yyq2009:

    Unfortunately there is currently no user guide and documentation. This is because we are still not 100% sure if the API won’t change anymore. We are still looking for feedback from the community.

    @satan:

    Yes, that’s the recommended way to do it. Thanks. :)

    #22640

    yyq2009
    Participant

    Thanks for your replies, it’s very helpful.

    #22641

    Kalpana
    Participant

    I am implementing rewrite in my project and want to have access to Rewrite documentation or API as that would be hepful

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

You must be logged in to reply to this topic.

Comments are closed.