Forum Discussion
Dachicourt_Fabi
Nimbostratus
Jan 07, 2005Using format strings in version 9
the string %h %p et %u don't work on version 9
for exemple, a rule like
rule my_rule {
if ([HTTP::uri] ends_with "baz") {
redirect to "https://%h:8080/%u/"
}
else {
use pool web_pool
}
}
don't work anymore.
Do you know a way to do this in version 9 ?
- unRuleY_95363Historic F5 AccountThese special format strings were dropped because it would require unnecessary changes to the native Tcl processing. Instead, simply use the '[' ']' evaluation and the appropriate F5 Tcl command. Here's what your rule would look like:
rule my_rule { when HTTP_REQUEST { if { [HTTP::uri] ends_with "baz" } { redirect to "https://[HTTP::host]:8080/[HTTP::uri]/" } else { use pool web_pool } } }
- For those interested, the F5 TCL commands are documented in the user manual as well as in the Docs and Tips section of DevCentral. The tip on "Querying Header and Content Data" can be found here:
- Brian_Gupta_115
Nimbostratus
Joe,when HTTP_REQUEST { redirect to "https://[URI::host][HTTP::uri]" }
when HTTP_REQUEST { redirect to "https://[HTTP::host][HTTP::uri]" }
- drteeth_127330Historic F5 AccountThe URI commands can be used to extract individual field components from a URI. For example,
should be equivalent to[URI::query [HTTP::uri]]
However, the protocol, host, and port commands are only meaningful when used with a full URI, e.g. http://www.foo.com/bar.html. This is the problem that you encountered.[HTTP::query]
- bl0ndie_127134Historic F5 AccountHTTP::uri returns the URI that is sent on the GET/POST request. This normally means that it will not have the protocol or host strings, at least not in the same way the user may have typed into the user agent. The exception being proxy requests, which will have the full URI.
URI::protocol Extracts the protocol part from the URI string that you specify. URI::basename Extracts the basename part from the URI string that you specify. URI::path Extracts the path from the URI string that you specify. URI::query Extracts the query part from the URI string that you specify. URI::host Extracts the host part from the URI string that you specify. URI::compare Compares URIs as recommended by RFC 2616 section 3.2.3. URI::decode Returns the decoded URI string. URI::encode Returns the encoded URI string URI::port Extracts the port part from the URI string that you specify.
- Brian_Gupta_115
Nimbostratus
One thing that confused me is your terminology. In "web" terminolgy I thought a URL consisted of protocol://hostname:port/uri - rapmaster_c_127Historic F5 AccountI'm not sure I agree with you. Here's a website that sums up our take on URI vs URL vs URN.
- Loc_Pham_101863Historic F5 AccountFurther clarifications/recommendations by W3C on URI vs. URL vs. URN. Note the Contemporary View.
- Brian_Gupta_115
Nimbostratus
Thanks for the clrification.
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