Redirect instead of Forward

Splash Forums Rewrite Users Redirect instead of Forward

This topic contains 5 replies, has 3 voices, and was last updated by  Lincoln Baxter III 2 years, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #25329

    defuchs
    Participant

    I’m struggling with this:

    config.addRule( Join.path( “/from/{path}” ).to( “/to.html” ) )

    But this is always doing a forward. Sometimes we need redirects, but with Parametrization.

    So the user should be redirected (and see in the url) => “/to.html?path=foo”

    Is this anyhow possible?

    #25330

    A join will always use a forward. If you want a redirect, use a rule like this:

    .addRule()
    .when(Direction.isInbound().and(Path.matches("/from/{path}")))
    .perform(Redirect.temporary("/to.html"))
    
    #25331

    defuchs
    Participant

    Thx, but this version is not adding the parameters as Query-Params:

    ConfigurationRuleBuilderPerform rule = config.addRule()
        .when(Direction.isInbound().and(Path.matches("/{key}")))
        .perform(Redirect.temporary("/foo.html"))
        .where("key").matches("[a-z0-9]{8}")
    

    from “/asdfasdf” this redirects me to “/foo.html” instead of “/foo.html?key=asdfasdf”

    any idea?

    #25332

    AFAIK you have to add the query parameter manually to the redirection target. Something like this:

    .perform(Redirect.temporary("/foo.html?key={key}"))
    
    #25333

    Yeah, actually you need to add the query parameters directly in this case:

    
    ConfigurationRuleBuilderPerform rule = config.addRule()
    .when(
       Direction.isInbound().and(
       Path.matches(“/{key}”).and(
       Query.matches("{query}")))
    )
    .perform(Redirect.temporary(“/foo.html?{query}”))
    .where(“key”).matches(“[a-z0-9]{8}”)
    .where("query").matches(".*")
    
    #25334

    Ah yeah, Christian’s example is probably more what you want.

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

You must be logged in to reply to this topic.

Comments are closed.