Forum Discussion
Joshua_106551
Nimbostratus
Feb 25, 2011how do I append a simple URI
I am looking to take a simple url and add "/sc/pol" every time the request comes through.
hoolio
Cirrostratus
Feb 25, 2011Nice one stjbrown. You could add a sanity check that the path doesn't already have the string as well.
Joshua, do you want to append /sc/pol to the HTTP path (/path/to/file.ext) or the URI (/path/to/file.ext?param1=value1¶m2=value2)?
Here is an example of the first option:
when HTTP_REQUEST{
if {[HTTP::host] contains "test" and not ([HTTP::path] ends_with "/sc/pol") }{
Due to a bug in v10.0 - 10.2.1, HTTP::path truncates the HTTP query string if present.
This is described in CR142756. This should be fixed in 10.2.1HF1.
Check if there is a query string
if {[HTTP::query] eq ""}{
No query string, so append the string to the path
HTTP::uri "[HTTP::uri]/sc/pol"
} else {
Append the string to the path and re-append the query string
HTTP::uri "[HTTP::path]/sc/pol?[HTTP::query]"
}
}
}
And an example of the second option:
when HTTP_REQUEST{
if {[HTTP::host] contains "test" and not ([HTTP::uri] ends_with "/sc/pol") }{
HTTP::uri "[HTTP::uri]/sc/pol"
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects