For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

TMAdmin's avatar
TMAdmin
Icon for Nimbostratus rankNimbostratus
Apr 29, 2015

Rewrite URI while keeping the URI query

Hi,

 

I am trying to rewrite the URI while keeping the URI query intact Ideas anyone? Below is the code I have attempted to use.

 

Minor note: If the request is sent without any query parameters, we still need to rewrite the URI - just no Query string needs to be added to the URI.

 

    when HTTP_REQUEST {
    if { [HTTP::host] equals "some.domain.name" and [HTTP::uri] equals "/jsp/cactus/cactusGardens.jsp" and [URI::query [HTTP::uri]] ne ""}{
    set q [URI::query [HTTP::uri] query]
        }
    if { [HTTP::host] equals "some.domain.name" and [HTTP::uri] equals "/jsp/cactus/cactusGardens.jsp" and [URI::query [HTTP::uri]] ne ""}{
   HTTP::uri "/members/Gardens.jsp?$q"
        }
    if { [HTTP::host] equals "some.domain.name" and [HTTP::uri] equals "/jsp/cactus/cactusGardens.jsp"}{
        HTTP::uri "/members/Gardens.jsp"
        }
}

2 Replies

  • Since you only want to modify the path portion of the URI, could you do something like this:

    when HTTP_REQUEST
        if { ([HTTP::host] equals "some.domain.name") and ([HTTP::path] equals "/jsp/cactus/cactusGardens.jsp") } {
            [HTTP::path] "/my/new/path.jsp"
        }
    }
    

    I believe that should only modify the path portion of the URI>

  • Hello Robert. It was pretty close for me to work with. I did not know the use of HTTP::path - now I do. Thanks. This is what worked eventually:

    when HTTP_REQUEST {
        if { ([HTTP::host] equals "some.domain.com") and ([HTTP::path] equals "/jsp/cactus/cactusGardens.jsp") } {
            HTTP::path "/members/Gardens.jsp"
        }
    }