Forum Discussion
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>
- TMAdmin
Nimbostratus
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" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com