Forum Discussion
When to use HTTP::uri vs HTTP::path, contains vs matches
When should I be using the HTTP::uri versus the HTTP::path in an iRule? Second part of the question is should I be using a "contains" or "matches" for the following...
Sample uri, http://www.test.com/dir/page.php?=data
when HTTP_REQUEST {
if { [HTTP::uri] contains "php" } {
pool php_pool
}
}
when HTTP_REQUEST {
if { [HTTP::path] contains ".php" } {
pool php_pool
}
}
If I want to do pool selection based on the content type, in this case it's a php, which would be the least cpu expensive route? Since the URI may not end with "php" would this need to be a contains or is there another method that is recommended?
Thanks in advance!
- Colin_Walker_12Historic F5 AccountWhat I'd recommend doing is logging each one to see what data each returns, so you know which data set you actually want to work with.
when HTTP_REQUEST { log local0. "This is the HTTP URI [HTTP::uri]" log local0. "This is the HTTP Path [HTTP::path]" }
when HTTP_REQUEST { if { [HTTP::path] ends_with ".php" } { pool php_pool } }
- nemmankNimbostratus
Simply put, if you are calling the HTTP::path, you are simply asking the iRule to apply your "if statement" to the HTTP::uri in the http traffic up to where it sees a query sign .i.e "?" .
In your case, http://www.test.com/dir/page.php?=data
HTTP::path = /dir/page.php
HTTP::uri = /dir/page.php?=data
Whichever you choose, the operand in the "if statement" will apply on the HTTP:: content.
when HTTP_REQUEST { if {[HTTP::uri] contains "php" } { pool php_pool } }
OR
when HTTP_REQUEST { if { [HTTP::path] contains ".php" } { pool php_pool } }
Will give you the same result.
I hope this helps :)
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