Question about redirect with pretty faces

Splash Forums PrettyFaces Users Question about redirect with pretty faces

Tagged: ,

This topic contains 7 replies, has 2 voices, and was last updated by  balteo 6 years, 8 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17868

    balteo
    Participant

    Hello,

    I would like for users who type in a url of this type:

    /lang/#{accueilView.language}/sculpture/#{sculptureView.titre}-#{sculptureView.id}

    to be redirected to the url of the following type:

    /lang/#{accueilView.language}/galerie/sculpture/#{sculptureView.titre}-#{sculptureView.id} (notice the ‘galerie’ bit that has been added).

    Once the redirect is done, the second type of url should be displayed in the browser address bar.

    Here is what I tried:

    <rewrite match=”/lang/#{accueilView.language}/sculpture/#{sculptureView.titre}-#{sculptureView.id}” substitute=”/lang/#{accueilView.language}/galerie/sculpture/#{sculptureView.titre}-#{sculptureView.id}” redirect=”301″/>

    However, it seems to be expecting a regexp.

    Can anyone help please?

    Thanks in advance,

    Julien.

    #20656

    Not to sound unhelpful, but yes, use a regexp :) Is there something more specific you wanted help with?

    Here are some regex tutorials:

    http://ocpsoft.com/opensource/guide-to-regular-expressions-in-java-part-1/

    http://ocpsoft.com/opensource/guide-to-regular-expressions-in-java-part-2/

    #20657

    Ah… I think I see what you want…

    You want to insert the “galerie” word, yes?

    It would look something like this:

    <rewrite match="(part1/)(part2)" substitute="$1galerie/$2" />

    Dollar signs ‘$’ followed by a number ‘$6’ correspond to the relative match group (parenthesis):

    0(1(2)(3))(4)(5(6))

    Where 0 is the entire matched text.

    #20658

    balteo
    Participant

    I am absolutely required to use regexp or is there another pretty faces tag I can use in order to achieve what I want? (The trouble is that I don’t know regexp very well…)

    Julien.

    #20659
    #20660

    balteo
    Participant

    I am going to have a look at the regexp I think.

    Thanks Lincoln,

    J.

    #20661

    balteo
    Participant

    Hello again Lincoln,

    The tutorial about regexp is neat. Still I must be getting something wrong with this:

    <rewrite match=”/lang/(fr|en)/sculpture/(.+)-(\d+)” substitute=”/lang/$1/galerie/sculpture/$2-$3″ redirect=”301″/>

    The above regexp does not match with this:

    http://localhost:8080/jeanbaptistemartin/lang/fr/sculpture/La+pose-3&#8221;

    At least I get a 404 when inputing this URL.

    Can you help?

    Thanks in advance,

    J.

    #20662

    balteo
    Participant

    Sorted!!

    I changed the (\d+) for (d+) and it works!!

    Thanks!

    J.

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

You must be logged in to reply to this topic.

Comments are closed.