Forum Discussion
HTTPS REDIRECTION : Specific NODE using iRULE
I wrote a simplified variant of your iRule. Tested and works as expected.
when HTTP_REQUEST {
if { [HTTP::host] equals "www.myfancydomain.com" && [HTTP::uri] starts_with "/test" } {
node 10.100.153.40 3000
}
}Note that I am matching the HTTP::host with equals, not with contains, because HTTP::host should be an exact match anyways.
Also I used HTTP::uri instead of HTTP::path and, but more important, I use starts_with, because HTTP::uri might also be /test/image1.jpg, test/index.html...
Differences between are explained here:
https://clouddocs.f5.com/api/irules/HTTP__path.html
https://clouddocs.f5.com/api/irules/HTTP__uri.html
Differences between contains, equals, starts_with and so on here:
https://devcentral.f5.com/s/articles/irules-101-02-if-and-expressions
And since you are always matching the same HTTP::host value, you might want to remove that check from your iRule logic and go for a switch statement to only match the HTTP::uri. Something like this.
switch -glob [HTTP::uri] {
"/foo*" {
# this will match on any string that starts with "/foo"
}
"*bar" {
# this will match on any string that ends with "bar"
}....For details see here: https://devcentral.f5.com/s/articles/irules-101-04-switch
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
