Forum Discussion
Skuba_85554
Nimbostratus
Oct 13, 2010is this line correct?!
hi everyone
could you confirm whether line 2 is correct? it only used to contain "www.abc.com" but i've added the "or" statement and i'm not sure if it's entirely correct...
---------------------------------------------
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] starts_with "www.abc.com" or "www.def.com"} {
if { [string tolower [HTTP::uri]] contains "secure" } {
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
elseif { [matchclass [string tolower [HTTP::uri]] starts_with $::redirect_class] } {
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
else {
use pool my_pool
}
}
else {
use pool my_pool
}
---------------------------------------------
thank you
2 Replies
- Ben_95489
Nimbostratus
Hey Skuba,
I believe you'll need to actually define the whole criteria again. For example:if { ([string tolower [HTTP::host]] starts_with "www.abc.com") or ([string tolower [HTTP::host]] starts_with "www.def.com")} {
It probably isn't critical, but you might want to perform the tolower to make a variable instead of performing the operation twiceset hostval [string tolower [HTTP::host]] if { ($hostval starts_with "www.abc.com") or ($hostval starts_with "www.def.com")} {
I believe that the example you used would do is evaluate if "www.def.com" is true - which it should always be (i.e. similar to a "while true" statement). There are some more details on the 'or' operator here, too: http://devcentral.f5.com/wiki/default.aspx/iRules/or.html
// Ben - hoolio
Cirrostratus
Good info Ben. You could also use a switch statement to check the host value set to lowercase:switch [string tolower [HTTP::host]] { "www.abc.com" - "www.def.com" { Exact match for www.abc.com or www.def.com } default { No match } }
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
